<< A short explanation of the NoSQL data model. | Home | Federated Unified Query Language - Announcement >>

Simplified JSon = Ison [EyeSon]

JSON is great, but a pain to write as a human and very noisy to read.

These rules do not interfere with existing the JSON document interpretation but only assign a meaning to documents, that have no equivalent in basic JSON.

I think it is not necessary to deviate from original the JSON style as YAML does to achieve a considerable improvement in usability for humans.

I love JSON's structural expressiveness, but hate its noisy writing. Looking at the Syntax it is possible to come up with some rules that extend JSON at the lexical level.

Here we go:

  1. Values, that are simple words or numbers do not require quotes. (start with a letter and contain only letters, digits or underscores)
  2. Sequences of the symbols . + - * / & % < > | = $ € ~ ! § ^ @ ? # are considered values and do not require quotes and they separate from simple words, numbers and strings.
  3. Elements of an array may be separated by blanks/tabs and such an array may be embedded in an array separated by commas.
  4. Arrays do not require brackets if they are a value in a map or if it is the top level array. An array without a bracket is closed the first newline after all embedded compounds are closed. If the line started with an object entry, that is closed as well.
  5. A map entry with an array value may be written as key[valuevaluelist] and a map entry with a map as value as key{ mapentries }.
  6. If a file does not start with an opening brace or bracket but with a 'string colon' pattern, then the top level of the file is a map otherwise it is an array.
  7. a colon and string appearing directly after an opening brace, opening bracket or opening parenthese creates an anchor (buffer wide key) that can be referenced by the same notation appearing as a value.

Before I start implementing it here some examples:


Example:

a b c 3 4.5 "a.b,c and e"
is the same as
a,b,c,3,4.5,"a.b,c and e"
an in json:
["a","b","c","3","4.5","a.b,c and e"]

Example 2:

x: public static int
y: private float
=
{
"x": ["public", "static", "int"],
"y": ["private" "float"],
}

Example 3:
x: public static list[int] = [2,3,5,7,11]
=
{
"x":["public","static","list", ["int"], "=", ["2","3","5","7","11"]],
}


Examples for the newline handling rule
a,b,c++ x,y,z
3 5 7
=
[["a","b",["c", "++", "x"], "y", "z"],["3", "5", "7"]]

{a :3, b:5} {
x: a b,
"another key"(value "second element" + "this is the fourth value because the + is the third element") 
}
[{"a": "3", "b": 5"}, {"x": ["a", "b"]}]


Examples for anchors and references:
{:outer
[:79 :outer]
x: :79
}

This creates a recursive data structure. The outer object is assigned the anchor (address) called outer.
The list it contains references its parent via :outer.
The list is assigned the anchor :79.
The list if refernced from its sibling entry with the key x.


Basically we are treating : ' ' , as operators that bind in this order.
(the colon binds stronger than blanks, which bind stronger than the commas)
The invisible separator between a value and a symbol sequence is treated like a blank.
Note, that the symbol sequence rule allows us to use these symbols without quotation marks, but we only tokenize them and do not parse them into an expression tree.

Tags : , ,


Re: Simplified JSon = Ison [EyeSon]

very interesting idea. thanks for the presentation.

 

 


Add a comment Send a TrackBack