2 ms·
I am now going to propose the key-value-inline-notation: KVIN. If JSON is that kid in the early '90s who had a l33t 286, then KVIN is JSON's older, iRoc driving
by thechao 8y ago
I am now going to propose the key-value-inline-notation: KVIN. If JSON is that kid in the early '90s who had a l33t 286, then KVIN is JSON's older, iRoc driving brother. KVIN has a 'stache that all the girls love. (It's a little thinner than Magnum P.I.s 'stache, right now.)
A KVIN file follows one simple pattern: it's a list of key-values or comments. Comments are any line that starts with any amount of whitespace and then a '#'. A key-value starts with a key, ends with a value, and has a '=' in the middle:
key = value
A key is made up of any valid C-identifier or C-numeric expression. You can 'chain' keys together with '.'s:
key ::= key [. axis] | axis
axis ::= c-identifier | c-number
A value is any valid c-identifier, c-number, or "byte string". A byte string starts with a '"', ends with a '"'. If you want to include a '"' then you have to escape with a '\'. If you want to include a '\', then you '\' the '\'. All whitespace is included in a byte-string: even a '\n'!
Strangely, KVIN understands relative paths. If a key starts with '.' then that means it's relative to the path just above it. Each '.' means 'go up one level from the last value':
foo.bar = 0
.baz = 2
Would be a JSON like this:
{ "foo" : { "bar" : 0, "baz" : 2 } }
KVIN has one final trick, besides the busted old turbo he's been trying to get in his iRoc: he knows how to autonumber a list:
foo.10 = a
.# = b
.# = c
.# = d
Which would be the JSON:
{ "foo" : [ ..., a, b, c, d ] }
With 'a' starting at index '10'. (The base index of arrays is 0.)
I've got code laying around, somewhere, that implements KVIN.