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

Function decode_payload_to_json

nodedb/src/control/server/http/routes/query.rs:276–288  ·  view source on GitHub ↗

Decode a Data Plane response payload to JSON. Tries MessagePack first (primary format), then JSON passthrough.

(payload: &[u8])

Source from the content-addressed store, hash-verified

274///
275/// Tries MessagePack first (primary format), then JSON passthrough.
276fn decode_payload_to_json(payload: &[u8]) -> Result<serde_json::Value, ()> {
277 // Try MessagePack.
278 if let Ok(val) = nodedb_types::json_from_msgpack(payload) {
279 return Ok(val);
280 }
281
282 // Try JSON passthrough.
283 if let Ok(val) = sonic_rs::from_slice::<serde_json::Value>(payload) {
284 return Ok(val);
285 }
286
287 Err(())
288}
289
290/// Convert pgwire Response vec to JSON rows (for DDL results).
291fn responses_to_json(responses: Vec<pgwire::api::results::Response>) -> Vec<serde_json::Value> {

Callers 15

queryFunction · 0.70
query_ndjsonFunction · 0.70
handle_incrbyfloatFunction · 0.50
handle_getsetFunction · 0.50
handle_zscoreFunction · 0.50
rate_checkFunction · 0.50
read_ttl_msFunction · 0.50
dispatch_and_respondFunction · 0.50
transferFunction · 0.50

Calls 1

json_from_msgpackFunction · 0.85