JSON - Preferred Marshaling

The TCF message data format is service specific. Since service specifications are separate from the protocol specification, a service designer can choose any data format that suits the service requirements best. However, to promote better compatibility and to simplify service design and implementation, we recommend using JSON for data formatting.

JSON (pronounced like the English given name Jason), which stands for "JavaScript Object Notation", is a lightweight, text-based, language-independent computer data interchange format. JSON is a subset of the object literal notation of JavaScript but its use does not require JavaScript.

JSON represents data with the same basic types that programming languages use. JSON's basic types are:

The structures used in most programming languages easily map directly onto JSON's structures, and back again.

JSON maps data onto Unicode string. Then the string is mapped onto array of bytes using UTF-8 encoding.

JSON specification:


<object>
    ⇒ {}
    ⇒ { <members> }

<members><string> : <value><members> , <string> : <value>

<array>
    ⇒ []
    ⇒ [ <elements> ]

<elements><value><elements> , <value>

<value><string><number><object><array><boolean>
    ⇒ null

<boolean>
    ⇒ true
    ⇒ false

<string>
    ⇒ ""
    ⇒ " <chars> "

<chars><char><chars> <char>

<char>
    ⇒ <any Unicode except " or \ or control>
    ⇒ \"
    ⇒ \\
    ⇒ \/
    ⇒ \b
    ⇒ \f
    ⇒ \n
    ⇒ \r
    ⇒ \t
    ⇒ \u <four-hex-digits>

<number>
    ⇒ <int>
    ⇒ <int> <fraction>
    ⇒ <int> <exponent>
    ⇒ <int> <fraction> <exponent>

<int><digit>
    ⇒ <digit 1-9> <digits>
    ⇒ - <digit>
    ⇒ - <digit 1-9> <digits>

<fraction>
    ⇒ . <digits>

<exponent><e> <digits>

<digits><digit>
    ⇒ <digits> <digit>

<e>
    ⇒ e
    ⇒ e+
    ⇒ e-
    ⇒ E
    ⇒ E+
    ⇒ E-

See www.json.org for more details.

Examples

This is a JSON array containing two objects:

   [
       {
          "Precision": "zip",
          "Latitude":  37.7668,
          "Longitude": -122.3959,
          "City":      "SAN FRANCISCO",
          "State":     "CA",
          "Zip":       "94107",
          "Country":   "US"
       },
       {
          "Precision": "zip",
          "Latitude":  37.371991,
          "Longitude": -122.026020,
          "City":      "SUNNYVALE",
          "State":     "CA",
          "Zip":       "94085",
          "Country":   "US"
       }
   ]