# Syntax
# Cheatsheet
This document shows the features of the Jsonic syntax:
// jsonic // JSON
// cheat... # comments
/*
* ...sheet!
*/
# implicit top level {
a: # implicit null "a": null,
b: 1 # optional comma "b": 1,
c: 1
c: 2 # last duplicate wins "c": 2,
d: f: 3 # key chains "d": {
d: g: h: 4 # object merging "f": 3,
"g": {
"h": 4
}
}
TODO
}
# Railroad Diagrams
jsonic
After parsing, either an object (map), an array
(list), or a scalar value is returned. An empty document is
considered valid and returns undefined
. While map
and list are strictly redundant here as they can be children of
value, implicit maps (no surrounding braces {}
)
and implicit lists (no surrounding square brackets []
)
are special cases at the top level.
map
One or more keys may preceed a value, creating child maps as
needed. Missing values are null
. Spurious commas are not
allowed. Key-value pairs can be separated by space and new lines.
list
List values are separated by space, commas and new
lines. A trailing comma is ignored. A comma without a preceding value
inserts an implicit null
.
value
A value can be surrounded by optional space (To match json.org, our non-empty space must be optional).
key
Keys are verbatim source characters including unquoted text, number and literal value representations, but excluding punctuation ({}[]...).
sep
Commas, spaces, new lines, and nothing, all separate values equivalently.
space
There must be at least one space character in the space token (unlike json.org—thus we make space optional elsewhere as needed). Space can contain one or comments.
string
Quoted strings (using «"'`») work as in JavaScript, including escaping. Triple single quotes operate as backticks, but remove the indent from each line.
number
Number literals work as in JavaScript. Underscore can be used to separate digits.
comment
Comments work as in JavaScript. Single line comments can also be introduced with «#». Balanced comments can nest.
← Options