Skip to main content

Module json

Module json 

Expand description

JSON output emitter for all analyses.

Most analyses emit their rows directly via write_json — a single generic over any serde::Serialize slice. The two exceptions are revisions (whose (String, u32) tuple needs a struct wrapping for named-field JSON output) and communities (whose output is a wrapper struct carrying the row array plus partition-level summary statistics, not the rows alone).

CLI dispatch calls write_json::<HotspotRow>(&rows, &mut out) directly with a turbofished row type — the same pattern the output::ndjson::write_ndjson emitter uses. Per-analysis wrapper shims (write_hotspots_json, write_code_health_json, etc.) were retired in commit b2efe20’s successor: 27 shims removed, 33 call sites updated to use the generic.

Functions§

write_communities_json
communities emitter — emits the wrapper struct (rows + modularity + community_count), not just the row array — the partition-level summary is the headline metric and JSON consumers expect it alongside the per-file mapping.
write_json
Generic JSON emitter. Serialises any serde::Serialize slice as a pretty-printed JSON array. The pretty form matches the historic shape from the pre-shim era; downstream consumers that expect stream-parseable single-row-per-line semantics should use --format ndjson instead.
write_revisions_json
revisions emitter — the tuple (path, n_revs) is serialised as a named-field struct so JSON consumers see {"entity": "...", "n_revs": N} rather than ["...", N] (which would be the default tuple serialisation).