KVON
-

Key Value Object Notation


Intro

KVON is a human readable data serialization format. Its specifications are described in the following sections, however it can be quickly summarized in the following blocks:

# defining keys with values
key: 'value'
'key with spaces': 'value'

# keys can also exist without values
key-without-value: null
key-without-value # `: null` can be omitted

# primitives
number: 42
string: 'str'
boolean: true
'multi line string':|
	line 1
	line 2
	line 3

# nesting keys - creating objects
a:
	1: '1'
	2: '2'
b:
	3: '3'
	4: '4'

# inlined arrays
array: [1 true 'str' [true false]]

# multi-dimensional arrays
multi-dim-array:--
	# primitives and inlined arrays can be
	# placed on one line
	- 'str 1' 'str 2' [0 1 [true false]]
	# objects and multi line strings have to be
	# placed on separate lines
	- key: 'value'
	- |
		line 1
		line 2
		line 3



Specifications

Objects

Objects are collections of keys-value pairs. When the key's value is a primitive (number, string, boolean), or an array of primitives, the key-value pair can be written in one line.
If the value is an object then each of the following keys must be written in a new line and indented to the right compared to their root. If the value is omitted it will be assumed to be null.
Consider the following KVON and equivalent JSON:


a:
	1: '1'
	2: 2
	3: # empty object
	4 # key with null value
	5: null # key with null value

{
	"a": {
		"1": "1",
		"2": 2,
		"3": {},
		"4": null,
		"5": null
	}
}

Strings

There are two types of string syntaxes: single and multi line. Single line strings must be delimited with either single quotes or double quotes. If the string itself contains quotes, it can be delimited with multiple quotes. For example: if a string contains the character `'`, it can be delimited with `"` or `'''` in order for the `'` not to count as a delimiter.
Multi line strings are initiated with the `|` character and the lines must come below it, and indented forward.
Consider the following KVON and equivalent JSON:


a: ' "b" '
b: " 'b' "
c: '' 'b' ''
d: "" "b" ""
e: |
	line-1
		line-2
	line-3

{
	"a": " \"b\" ",
	"b": " 'b' ",
	"c": " 'b' ",
	"d": " \"b\" ",
	"e": "line-1\n\tline-2\nline-3" 
}

Arrays

There are two types of array syntaxes: single and multi line arrays. Single line arrays can contain primitives, and sub single line arrays. Multi line arrays can contain any value, every line can contain any number of values. However, Multi line strings, multi line arrays, and objects must be placed on their lines. Objects are initiated with `:--` if they come after a key, and with a `--` if they come as one of a different multi line array's values.
Consider the following KVON and equivalent JSON:


arr: [1 2 [true false] 'hello']
multi-line-array:--
	- 1 2 [true false] 'hello'
	- key: 'value'
	--
		- 'a' 'b'
		- 'c'
	- |
		line-1 
		line-2 

{
	"arr": [1, 2, [true, false], 'hello'],
	"multi-line-array": [
		1,
		2,
		[true, false],
		'hello',
		{
			"key": 'value'
		},
		["a", "b", "c"],
		"line-1\nline-2"
	]
}

Indention

KVON allows both tab and space indention. KVON parser will auto detect the indention by the first time it is used.




Libraries

Additional language support is in progress...