jsonic accepts standard JSON and extends it with the relaxations described below. All extensions are optional -- valid JSON always parses correctly.
Standard JSON objects work as expected. jsonic also supports:
Keys do not need quotes when they contain only word characters (letters, digits, underscore) or spaces followed by a colon.
{a: 1, b: 2} → {"a": 1, "b": 2}
{my key: "value"} → {"my key": "value"}
The outer {} braces are optional when the input contains key-value pairs.
a:1, b:2 → {"a": 1, "b": 2}
When the same key appears multiple times, object values are deep-merged.
a:{b:1}, a:{c:2} → {"a": {"b": 1, "c": 2}}
Nested objects can be expressed inline using chained colons.
a:b:1, a:c:2 → {"a": {"b": 1, "c": 2}}
Standard JSON arrays work as expected. jsonic also supports:
When the input contains comma- or newline-separated values without colons, it is parsed as an array.
a, b, c → ["a", "b", "c"]
1, 2, 3 → [1, 2, 3]
By default, key-value pairs inside arrays are allowed.
[a:1, b:2] → [{"a": 1}, {"b": 2}]
This can be controlled with the list.property option.
Double quotes, single quotes, and backticks all work as string delimiters.
"hello" 'hello' `hello`
Values that are not numbers, booleans, or null are treated as unquoted strings. Unquoted strings extend to the next structural character (comma, colon, bracket, brace) or end of line.
{a: hello world} → {"a": "hello world"}
Backtick strings can span multiple lines. Newlines are preserved.
`line one
line two` → "line one\nline two"
Triple-quoted strings ('''...''') strip the common leading indentation.
'''
line one
line two
''' → "line one\nline two"
All standard JSON number formats, plus:
| Format | Example | Value |
|---|---|---|
| Decimal | 42, 3.14, .5 |
42, 3.14, 0.5 |
| Signed | +1, -1 |
1, -1 |
| Scientific | 1e2, 1.5e-3 |
100, 0.0015 |
| Hexadecimal | 0xFF, 0x0a |
255, 10 |
| Octal | 0o17 |
15 |
| Binary | 0b1010 |
10 |
| Separators | 1_000_000 |
1000000 |
Three comment styles are supported by default:
# hash line comment
// slash line comment
/* block
comment */
Comments are discarded and do not appear in the output.
The following keywords are recognized (case-sensitive):
| Keyword | Value |
|---|---|
true |
true |
false |
false |
null |
null |
Custom keywords can be added via the value.def option.
Trailing commas are always allowed and ignored.
{a:1, b:2,} → {"a": 1, "b": 2}
[1, 2, 3,] → [1, 2, 3]
Unclosed { or [ at end-of-input are closed automatically. This can be
disabled with the rule.finish option.
{a:1 → {"a": 1}
[1, 2 → [1, 2]
Standard JSON escape sequences work in all quoted strings:
| Sequence | Character |
|---|---|
\\ |
Backslash |
\" |
Double quote |
\' |
Single quote |
\n |
Newline |
\r |
Carriage return |
\t |
Tab |
\b |
Backspace |
\f |
Form feed |
\uXXXX |
Unicode code point |
\xXX |
ASCII code point |