Skip to main content

to_canonical_string_pretty

Function to_canonical_string_pretty 

Source
pub fn to_canonical_string_pretty<T: Serialize>(value: &T) -> Result<String>
Expand description

Serialize to canonical pretty JSON: every object key is emitted in alphabetical order and the graph nodes / edges arrays are sorted by a stable key (id for nodes; from, to, kind for edges). This makes the output byte-stable for unchanged input — re-running the analysis never reorders keys (e.g. from HashMap iteration order) or array entries.

serde_json::Value is backed by a BTreeMap, so round-tripping through it yields alphabetical keys for free; we only sort the data arrays explicitly.