MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / json_roundtrip_through_msgpack

Function json_roundtrip_through_msgpack

nodedb/src/data/executor/doc_format.rs:152–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150
151 #[test]
152 fn json_roundtrip_through_msgpack() {
153 let original = serde_json::json!({"name": "alice", "age": 30, "tags": ["ml", "rust"]});
154 let json_bytes = serde_json::to_vec(&original).unwrap();
155
156 // Convert JSON → MessagePack.
157 let msgpack_bytes = json_to_msgpack(&json_bytes);
158 assert_ne!(
159 json_bytes, msgpack_bytes,
160 "should convert to different format"
161 );
162
163 // Decode from MessagePack.
164 let decoded = decode_document(&msgpack_bytes).unwrap();
165 assert_eq!(decoded, original);
166 }
167
168 #[test]
169 fn json_input_detected_correctly() {

Callers

nothing calls this directly

Calls 2

decode_documentFunction · 0.85
json_to_msgpackFunction · 0.70

Tested by

no test coverage detected