A data format that caters to humans and helps reduce the errors they make.
See the full intro at laktak.github.io/hjson.
{
# comments are useful
"rate": 1000 # specify in requests/second
# key names do not need to be placed in quotes
key: "value"
# most of the time you don't need quotes for strings
text: look ma, no quotes!
# commas are optional
commas:
{
one: 1
two: 2
}
# trailing commas are allowed
trailing:
{
one: 1,
two: 2,
}
# multiline string
haiku:
'''
JSON I love you.
But you strangle my expression.
This is so much better.
'''
# You can still use standard JSON
favNumbers: [ 1, 2, 3, 6, 42 ]
}
The Hjson syntax is a superset of JSON (see json.org) but allows you to
- omit
,
at the end of a line, - omit
""
for keys that contain onlyletters
anddigits
, - omit
""
for strings values that- do not start with a
digit
,-
,{
,[
or#
, - do not start with the keywords
true
,false
ornull
and - do not use escapes (The string terminates at the newline.)
- do not start with a
- add
# comments
(the parser treats comments like whitespace), - use multiline strings with proper whitespace handling:
- starts with triple quotes
'''
, whitespace on the first line is ignored '''
defines the head, on the following lines all whitespace up to this column is ignored- all other whitespace is assumed to be part of the string.
- ends with triple quotes
'''
.
- starts with triple quotes
- Hjson for JavaScript (Node.js/Browser)
- Conversion Tool/CLI (Node.js)
- Hjson Gulp Task
- Hjson for .Net/C#