Normal

Just like relational databases, JSON data structures can be normalised into a regular form that allows consistent patterns of access. Additional metadata is required in order to enable round trip transformation, indicated either by position in an array or a named property in an object.

object = { @:metadata, array }
array = [ metadata , contents ]
contents = object or scalar

This approach ensures:

  • all data is named by object property, and in an array of adjustable contents.
    Data items are thus accessed by the query [“name”][position].
  • all objects properties are arrays which can have 0 to many values.
    If a property already has an array value, then a true is inserted into the first position.
    If a property does not have an array value, then a false is inserted into the first position, and the second position contains the value.
  • all arrays are named.
    If an array is not contained in a named property, then an object is created with
    a property “@”:[“array”] and a property “$” which contains the array.
    If an array is already contained in an object with a property named “$” which also already has property named “@”, then “@” gets an array with “”array” in first position and the original value of “@” in second position. This enables multiple levels of escaping (re-normalisation) to enable round trip de-normalisation.