Introducing JSONS

I'm a computer programmer, and that means I'm lazy.  So lazy that I'll go out of my way doing extra work to save myself some extra effort.  Sounds paradoxical, and it is - it's just what happens to engineer types. In this case it meant that I've gotten awful tired of trying to force my code to properly terminate JSON lists, especially when I can't keep the whole shooting match in memory - for instance if I want to have the data safely stowed away in a file when the program crashes.

So to provide a mite bit easier programming, I decided to create yet another JSON variant.  This matches JSON in most respects, excepting as to how the root nod is handled: it doesn't exist. JSONS, JavaScript Object Notation Streaming, uses an implicitly declared root list instead of the normal explicitly declared root object.

Standard JSON storing a list of strings:

{
  "myList":[
    "halo",
    "whirled"
  ]
}

JSONS storing the same list of strings:

"halo",
"whirled",

Note the differences:

  1. There's no root object,
  2. The root is a list that's not actually written, only implicit,
  3. This root list is expected to have the last element end in a comma.

Now, I'm going to go out on a limb and explicitly require that every conforming implementation place the comma on the last element - it's not hard, and is easier than trying not to!

Now, while I've changed the list requirements for this special root list, nothing changed for entries in the list: entries are expected to be normal JSON syntax:

{"comment":["This is", "a normal list", "in an object"]},
"followed by a string, and then a number",
3.14159,
[1, 2, "and a standard heterogeneous list!"],

Of course, line breaks are purely optional, but are preferred - as long as they are ONLY the newline (0x10) character - none of that CRLF and CR noise.

If you want to build a parser, it's really simple: read in the string, prepend "[", trim off the trailing whitespace and the comma, append "]", and feed it into a common JSON parser.  Or you can code something up yourself that's more explicitly oriented, it's up to you and your laziness!