JSON is an example (and actual implementation) of what conventions are good for.

The whole "miracle" is just a few fundamental notions (which reflects the way this Universe is) put together. These fundamental notions are:

  • Set (a distinct group, an unordered collection) - pure abstraction - does not exist outside human mind.
  • Ordering (an actual physical ordering of atoms, basic determinism) - a concrete basis of everything.
    • Sequence (a sequence implies a particular order) - an abstraction reflecting a very basic, simplest structure (a Pair)
  • Structure (a molecule - a distinct arrangements of atoms)
    • a Structure implies an ordering, but could be viewed/treated as a Set (hiding the actual order, disallowing duplicates, the notion of membership only).
  • Nesting (the notion of having a deep structure, molecules combined)
  • Naming (referencing)

JSON is just a formalized textual representation of these notions.

braces represent the notion of grouping (a basic block)

{ }

a string (an ordered sequence of characters, belonging to a particular character set)

"This is a UTF-8 encoded string"

an ordered sequence of elements (of an array, a list or a structure)

[1, 2, 3]

a named slots (fields) of an aggregate (of a structure)

{"name": "value", "key": "data"}

structures can be nested

[{"Title":"Casablanca","Released":1942,"Actors":["Humphrey Bogart","Ingrid Bergman"]},{"Title":"Cool Hand Luke","Released":1967,"Color":true,"Actors":["Paul Newman"]},{"Title":"Bullitt","Released":1968,"Color":true,"Actors":["Steve McQueen","Jacqueline Bisset"]}]

In Go we would have literals for arrays

[]string{1: "one", 2: "two", 3: "three"}

for structs

Symbol{Slot1: "value", Slot2: "value"}

or maps

    "alice": 32,
    "bob":   34,


        {Title: "Casablanca", Year: 1942, Color: false,
                Actors: []string{"Humphrey Bogart", "Ingrid Bergman"}},
        {Title: "Cool Hand Luke", Year: 1967, Color: true,
                Actors: []string{"Paul Newman"}},
        {Title: "Bullitt", Year: 1968, Color: true,
                Actors: []string{"Steve McQueen", "Jacqueline Bisset"}},

Go is even more subtle - it allows partial initialization - omitted fields (slots) will be initialized with a corresponding zero-value of a slot's type

Last modified 4 years ago Last modified on Nov 3, 2017, 5:22:42 AM
Note: See TracWiki for help on using the wiki.