Skip to main content

Module json

Module json 

Source
Expand description

JSON ⇄ C0DATA conversion.

The intermediate Value tree and the to_value/from_value conversions are dependency-free and always available. The JSON text helpers ([to_json]/[from_json]) need the json feature, which pulls in serde_json.

Export never guesses: a positional record is an array, a keyed record an object, a group with a header row an array of objects, a reference {"$ref": "group/record/field"}.

Enums§

Value
An intermediate data tree. All scalars are strings; objects keep insertion order.

Functions§

export_body
A body: {file => groups} per named file, or the groups directly; a bare body (one unnamed group) exports as that group.
export_group
A group: with a header row, an array of objects; a single keyed record is an object; otherwise an array of its records.
export_record
A record: a keyed record is an object (last value wins for a duplicate key), a positional one an array.
from_value
Emit a Value tree as canonical C0DATA bytes. An object of groups becomes groups (one key wrapping an object of groups becomes a file); an array becomes one group named group_name; an object of scalars one group holding one map; a scalar one record.
to_value
Build a Value tree from C0DATA bytes (the first document’s body).