Search code examples
hjson

hjson: why does close brace have to be on a separate line?


This works: (update: but not as I was thinking! it actually sets b = "c, d: e")

a: [
   { b: c, d: e 
   }
]

and this works:

a: [
   { "b": "c", "d": "e" }
]

But this doesn't work. What about the hjson definition disallows the closing brace at the end of the line?

a: [
   { b: c, d: e }
]

Found ']' where a key name was expected
(check your syntax or use quotes if the key name
 includes {}[],: or whitespace): line 3 column 1 (char 23)

Solution

  • In Hjson a string without quotes is terminated by the newline, so your closing brace gets eaten by the quoteless string.

    When you write

    { b: c, d: e 
    }
    

    you are saying, give me a string that contains "c, d: e".

    You need to use either quotes

    { b: "c", d: "e" }
    

    or

    { 
      b: c
      d: e
    }