ARbitrary Structured Object Notation
Not to be confused with the criminal act of deliberately setting fire to property!
JSON is great until you need to encode an object with circular references:
var obj = {};objself = obj;JSON; // throws
Throwing an exception is lame, but even worse is muddling along as if everything is ok:
var a = {};var b = foo: 42 ;ax = ay = b;var c = JSON;assert; // fails
We need an object notation that supports circular and repeated references.
That's where ARSON
comes in:
var a = {};var b = foo: 42 ;ax = ay = b;var c = ARSON;assert; // no problem!
ARSON
is compact, often even more compact than JSON, because repeated objects are defined only once:
var a = {};var b = foo: 42 ;ax = ay = b;ARSON; // [{"x":1,"y":1},{"foo":2},42] vs. // {"x":{"foo":42},"y":{"foo":42}}
But that's not all! ARSON
can also encode undefined
, thanks to the fact that [][-1]
is always undefined
:
> ARSON'[{"foo":-1}]'> ARSON foo: undefined
It can also encode array holes:
> ARSON'[[-2,-2,-2,1,2],4,5]'> ARSON 4 5
Buffer
s:
> ARSON'[["Buffer","YXNkZg==","base64"]]'> ARSON<Buffer 61 73 64 66>
Date
s:
> ARSON'[["Date","2016-02-02T00:25:36.886Z"]]'> ARSONMon Feb 01 2016 19:25:36 GMT-
RegExp
s:
> ARSON'[["RegExp","asdf","img"]]'> ARSON/asdf/gim
Set
s:
> s = Set {}> sSet Set Set Object > ARSON'[["Set",0]]'> ARSONSet Set Set Object > _true
and Map
s:
> m = Map {}> mMap Map Map Object > mMap Map Map Object Object 5678 Map Object Object 5678 5678 Map Map Object Object 5678 Map Object Object 5678 5678 5678> ARSON'[["Map",1,2],[3,0],[0,4],1234,5678]'> ARSONMap Map Map Object Object 5678 Map Object Object 5678 5678 Map Map Object Object 5678 Map Object Object 5678 5678 5678> _ === 5678true