Skip to content

Commit 628da3e

Browse files
committed
feat: Deserialize binary to JSON
1 parent cffb046 commit 628da3e

File tree

3 files changed

+44
-22
lines changed

3 files changed

+44
-22
lines changed

Cargo.lock

+32-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ holochain_conductor_api = "0.4.1"
2323
holochain_types = "0.4.1"
2424
holochain_websocket = "0.4.1"
2525
serde = { version = "=1.0.203", features = ["derive"] }
26-
serde_json = "1.0.140"
26+
serde_json = { version = "1.0.140", git = "https://github.com/ThetaSinner/json.git", branch = "master" }
2727
thiserror = "2.0.11"
2828
tokio = { version = "1.43.0", features = ["rt-multi-thread", "macros", "net"] }
2929
tracing = "0.1.41"

src/transcode.rs

+11
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ mod tests {
5353
};
5454
use assert2::let_assert;
5555
use base64::{prelude::BASE64_URL_SAFE, Engine};
56+
use holochain_types::dna::ActionHash;
5657
use holochain_types::prelude::ExternIO;
5758
use serde::{Deserialize, Serialize};
5859

@@ -125,4 +126,14 @@ mod tests {
125126
let expected_json_response = serde_json::to_string(&response).unwrap();
126127
assert_eq!(json_response, expected_json_response);
127128
}
129+
130+
// TODO requires https://github.com/serde-rs/json/pull/1247
131+
#[test]
132+
fn deserialize_binary() {
133+
let output = ExternIO::encode(ActionHash::from_raw_32(vec![2; 32])).unwrap();
134+
135+
let json = hsb_to_json(&output).unwrap();
136+
137+
assert_eq!(json, "[132,41,36,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,32,73,61,253]");
138+
}
128139
}

0 commit comments

Comments
 (0)