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

Function json_to_display_string

nodedb/src/bridge/json_ops.rs:90–98  ·  view source on GitHub ↗

Convert a JSON value to a display string. - Strings: returned as-is (no quotes) - Null: empty string - Numbers/Bools: `.to_string()` - Objects/Arrays: JSON serialization

(v: &serde_json::Value)

Source from the content-addressed store, hash-verified

88/// - Numbers/Bools: `.to_string()`
89/// - Objects/Arrays: JSON serialization
90pub fn json_to_display_string(v: &serde_json::Value) -> String {
91 match v {
92 serde_json::Value::String(s) => s.clone(),
93 serde_json::Value::Null => String::new(),
94 serde_json::Value::Number(n) => n.to_string(),
95 serde_json::Value::Bool(b) => b.to_string(),
96 other => other.to_string(),
97 }
98}
99
100/// Convert a f64 to a JSON number, preferring integer representation.
101///

Callers 1

compare_jsonFunction · 0.70

Calls 2

to_stringMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected