jsonyx Specification¶
jsonyx allows minimal and unambiguous JSON deviations for developer convenience.
Example¶
{
/* Block */ // and line comments
"Missing commas": [1 2 3],
"NaN and infinity": [NaN, Infinity, -Infinity],
"Surrogates": "\ud800",
"Trailing comma": [0,],
"Unquoted keys": {key: "value"}
}
Grammar¶
Generated with RR - Railroad Diagram Generator by Gunther Rademacher.
jsonyx_document¶
A jsonyx document consists of a single value.
jsonyx_document ::= value
value¶
A value can be an object, array, string, number, true, false or
null.
value ::= whitespace
( object | array | string | number | 'true' | 'false' | 'null' )
whitespace
object¶
An object is an unordered set of key/value pairs enclosed in curly braces. Each key is followed by a colon and pairs are separated by commas or whitespace with an optional trailing comma.
object ::= '{' (
whitespace
| ( ( key ':' value ) ++ ( ',' | whitespace - '' ) ) ( ',' whitespace )?
) '}'
array¶
An array is an ordered collection of values enclosed in square brackets. Values are separated by commas or whitespace with an optional trailing comma.
array ::= '[' (
whitespace
| ( value ++ ( ',' | whitespace - '' ) ) ( ',' whitespace )?
) ']'
string¶
A string is a sequence of characters, wrapped in double quotes, using backslash escapes.
string ::= '"' (
[^"\#x0-#x1F]
| '\' ( ["\/bfnrt] | 'u' [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] )
)* '"'
number¶
A number is a signed decimal number, optionally in scientific notation or one
of the special values NaN, Infinity and -Infinity.
number ::= '-'? (
( '0' | [1-9] [0-9]* ) ( '.' [0-9]+ )? ( [eE] [+-]? [0-9]+ )?
| 'Infinity'
) | 'NaN'
key¶
A key can be a string or an identifier.
key ::= whitespace ( string | identifier ) whitespace
whitespace¶
Whitespace, including comments can be inserted between any pair of tokens.
whitespace ::= ( '//' [^#xA#xD]* | '/*' ( ( [^*]* '*'+ ) ++ [^*/] ) '/' | [#x9#xA#xD#x20] )*