Skip to content

Instantly share code, notes, and snippets.

@be5invis
Last active January 30, 2016 21:49
Show Gist options
  • Save be5invis/7a5dfa516b25be83c242 to your computer and use it in GitHub Desktop.
Save be5invis/7a5dfa516b25be83c242 to your computer and use it in GitHub Desktop.

COMPRESSED BIN JSON

document = stringtable ctortable value
stringtable = length string*length
ctortable = length constructor*length
constructor = 
	F0-FF value // Internal constructor
	00 key      // External constructor

value = 
	01 double
	02 string
	03 length value*length // array
	04 length pair*length // object
	05 // false
	06 // true
	07 // null
	08 // undefined
	09-0C RESERVED
	0D leader length value*length*arity // compact array
	0E length value*arity // constructor
	0F length // table string
	10-1F RESERVED
	20    RESERVED (high-precision number?)
	21 byte
	22 sbyte
	23 int16
	24 uint16
	25 int32
	26 uint32
	27 int64
	28 uint64
	29 single
	2A-2F RESERVED
	30-AF // fast integer 0-127
	B0-BF // fast negative
	C0-CF value*arity // fast array
	D0-DF pair*arity // fast object
	E0-EF value*arity // fast constructor
	F0-FF // slot

pair = key value
key =
	length // fast key
	FF string // raw key
string = length byte*length // utf-8 encoded. 36-bit length is necessary
length =
	0xxxxxxx
	110xxxxx 10xxxxxx
	1110xxxx 10xxxxxx 10xxxxxx
	11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
	111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
	1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
	11111110 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx

A polygon example

02 x y 01 F1 D2 01 F0 02 F1 C2 E0 21 00 21 00 E0 21 01 21 01
[{"x": 0, "y": 0}, {"x": 1, "y": 1}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment