Skip to content

tln/hjson

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Hjson, the Human JSON

A data format that caters to humans and helps reduce the errors they make.

Intro

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 ]
}

Syntax

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 only letters and digits,
  • omit "" for strings values that
    • do not start with a digit, -, {, [ or #,
    • do not start with the keywords true, false or null and
    • do not use escapes (The string terminates at the newline.)
  • 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 '''.

Download

Releases

No releases published

Packages

No packages published