Expand description
JSONC (JSON with Comments) parser and serializer.
Handles reading and writing JSONC files while preserving comments,
trailing commas, and formatting, using jsonc-parser’s CST API.
Strategy:
- Read: parse JSONC to clean JSON for serde deserialization.
- Write: if the destination file already has JSONC source, reconcile the
new value against the existing CST node-by-node so comments and
structural formatting around unchanged keys are preserved. When a key’s
value changes shape (scalar → object, array, etc.), the whole subtree is
replaced. New destinations fall back to
serde_json::to_string_pretty.
Structs§
- Jsonc
Handler - Handler for JSONC file operations.
Functions§
- read_
config - Read a config file and deserialize into the target type.
- read_
config_ to_ json - Read a config file (JSONC or JSON) and return clean JSON for deserialization.
- write_
config - Serialize a config value and write it to a file atomically.