TAO: examples

Note: This is subject to future work. Errors, ambiguities, and omissions are to be expected.

An example of data encoded in TAO, similar to a JSON sample from Wikipedia:

first name [John]
last name [Smith]
age [25]
address [
    street address [21 2nd Street]
    city [New York]
    state [NY]
    postal code [10021]
]
phone numbers [
    [
        type [home]
        number [212 555-1234]
    ]
    [
        type [fax]
        number [646 555-4567]
    ]
]

Another example:

songs [
    [
        title [Scarborough Fair / Canticle]
        length [3:10]
    ]
    [
        title [Patterns]
        length [2:45]
    ]
    [
        title [Cloudy]
        length [2:15]
    ]
]

with an equivalent JSON object for comparison:

{
    "songs": [
        {
            "title": "Scarborough Fair / Canticle",
            "length": "3:10"
        },
        {
            "title": "Patterns",
            "length": "2:45"
        },
        {
            "title": "Cloudy",
            "length": "2:15"
        }
    ]
}

An example with ops:

make a meta symbol an op to escape it:
`` or `[ or `]

An example with raw taos:

raw taos can be used to embed documents in any format
for example JSON`: raw [
{
  "id": 1,
  "tags": [
    "Foo"
  ]
}
]
or XML`: raw [
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"></xs:schema>
]
or S-expressions`: raw [
(defun factorial (x)
  (if (zerop x) 1
    (* x (factorial (- x 1)))))
]

See the interactive TAO parser for some more and to try out your own.

See also examples that compare TAO to other syntaxes and others throughout the sections of this website.