JSON-compatible data interchange format that's easy to write
LICENSE.md | ||
README.md | ||
son.sh | ||
test.sh | ||
util.sh |
Small Object Notation
Small Object Notation (SON) is a JSON-compatible data interchange format that aims to be simpler to write by hand and accept a wider range of inputs than JSON.
Here is an example of some SON:
first_name: John
last_name: Smith
address: {
street_address: "21 2nd Street"
city: New\ York
}
phone_numbers: {
{ type: home, number: "212 555-1234" }
{ type: office, number: 656\ 555-4567 }
}
children: {
Catherine /* block comments */
Thomas # and single-line comments
Trevor # ... are both supported
}
Features
- JSON-compatible
- any JSON object is also a valid SON object
- this is done by making
[]
and{}
interchangeable
- Quotes are optional
{ "hello there" }
=={ hello\ there }
- Commas are optional
- a comma at the end of the last value can be included without causing errors (unlike JSON)
- spaces can separate values and commas can be omitted
{ hello, there, }
=={ hello there }
- Arrays and structs are the same
- numbered keys are auto-assigned to values with no preceding key
{ general, kenobi }
=={ 0: general, 1: kenobi }
Languages
Currently, the only SON parser is only implemented for BASH. This is because
BASH does not have native support for any data interchange formats. The
original motivation for making this was to have a data interchange format
that's usable in BASH, with a more bash-like syntax compared to JSON. BASH also
provides nice syntax for writing string operations (eg. ${var%str}
= "give me
var
, but remove 'str' from the end")