- Directives --
.TYPEand.IGNOREdirectives - Definitions -- JSON Object and Arrary definitions
- Lexical Rules -- string and number matching rules
The .TYPE directive:
- Identifies a single property that names the JSG production type of a JSON object
- (Optionally) lists one or more production types that do not use the
.TYPEdiscriminator
.TYPE <type> [- <type> [<type> ...]] ;
| JSG | JSON | result |
|---|---|---|
| doc { a:. } | {"a":"hello"} | pass |
| {"type": "doc", "a":"hello"} | fail | |
| .TYPE type; doc {a:.} | {"type": "doc", "a":"hello"} | pass |
| {"type": "doc", "a":{"a":0}} | fail | |
| {"a":"hello"} | (depends on context) |
The .IGNORE directive identifies a list of properties to globally ignore.
.IGNORE <type> [<type> ...] ;
| JSG | JSON | result |
|---|---|---|
| doc {a:@string} | {"a":"hello"} | pass |
| {"id": "doc", "a":"hello"} | fail | |
| .IGNORE id, idx; doc {a:@string} | {"id": "doc", "a":"hello", "idx":243} | pass |
| {"id": "doc", "a":"hello", "foo":243} | fail |
A JSG definition consists of the definition name followed by the definition enclosed in curly braces ({ ... })
| JSG | Description |
|---|---|
<identifier> : <valueType> [<cardinality>] |
<identifier> is any valid JSON string, with the exception that the enclosing quotes can be double ("), single (') or omitted completely if the string consists solely of a-z, A-Z, 0-9 and @ characters. |
| Type | Description | Example |
|---|---|---|
| <quoted string> | Fixed value | doc {a:"hello"} |
| <builtin type> | Builtin JSON type (w/ extensions). Possible values are: @string : JSON string @number : JSON number@int : JSON number without ., e or E characters@bool: true or false@null : null@array : a JSON array ([ ... ])@object : a JSON object ( { ... }) |
doc {a:@number} |
| <any> | Any JSON type. Represented by a single dot (.) |
doc {a: .} |
| <pattern reference> | The name of a lexical pattern defined in the Lexical Rules | doc {a: HEX4 } @terminals HEX4: HEX HEX HEX HEX HEX : [0-9] |
| <identifier reference> | A reference to a JSG definition. | person {legal: name, alt: alias } name {first: @string, last: @string} alias [name] |
| (empty) | An empty object. | doc {} |
| <sequence> |