Expand description
JSON interchange functions for the gram codec.
These functions form the stable contract between the Rust gram-codec and native TypeScript/Python implementations. All cross-boundary communication uses the JSON interchange format documented in the data-model spec.
§JSON Interchange Format
The format is an array of AstPattern objects:
[
{
"subject": {
"identity": "alice",
"labels": ["Person"],
"properties": { "name": "Alice" }
},
"elements": []
}
]Property values use mixed serialization:
- Primitives: native JSON (string, number, boolean)
- Complex types: tagged objects
{ "type": "symbol"|"range"|"tagged"|"measurement", ... }
Functions§
- ast_
to_ pattern - Convert an
AstPatternback to a nativePattern<Subject>. - gram_
parse_ to_ json - Parse gram notation and return a JSON array string of
AstPatternobjects. - gram_
stringify_ from_ json - Serialize a JSON array of
AstPatternobjects back to gram notation. - gram_
validate_ to_ json - Validate gram notation and return an empty string on success, or an error message.