Skip to main content

Module json_ast

Module json_ast 

Source
Expand description

Shared JSONC-AST helpers for recovering exact dependency source positions (#613).

deps-npm and deps-composer each parse a JSON manifest’s semantic content (dependency names, version requirement strings, minimum-stability, …) via serde_json/crate::parse_json_checked, as before — this module is never a replacement for that.

What it replaces is how each crate previously recovered a dependency’s position: substring-scanning the raw manifest text for a section’s byte range, then for each name/version pattern within it (removed by #613, since it broke down for duplicate keys and same-named nested values — see find_json_section_byte_range’s removal in this same change). Reading positions directly off a position-preserving parse tree is correct by construction regardless of serde_json::Map iteration order, duplicate keys, or nested value shapes, mirroring crates/deps-deno/src/parser.rs’s original D6 design — generalized here for the “several named top-level sections” shape (dependencies/devDependencies, require/require-dev) that deno.json’s single flat imports map doesn’t have.

JsonSection keeps jsonc-parser’s own AST types out of every downstream crate’s public (and Cargo.toml direct-dependency) surface — only deps-core names jsonc_parser::ast types directly.

Structs§

JsonAst
A parsed JSON/JSONC document, used only to recover a named top-level section’s exact source positions — never a substitute for a caller’s own serde_json parse of the document’s semantic content.
JsonSection
One top-level section’s direct properties, indexed by name.

Functions§

find_last_prop
Finds the property named key among object’s own direct children, taking the last one if key occurs more than once.