In [1]:
from __future__ import unicode_literals, print_function
from axon.api import loads, dumps
AXON represents data with the help of compositions of several patterns of structuring and notation of data.
There are atomic values at the bottom level: unicode strings, integers, floats, decimals, dates/times, boolean and binary data in base64 encoding.
Complex data structures represented in AXON as compositions of anonymous and named data structures.
Anonymous data structure is dict, ordered dict, list, tuple:
key:value pairs.key:value pairs.Named data structure is a node. It has a name, can have oredered collection of attributes (name:value pairs) and can have oredered collection of values.
AXON uses three kind of syntax for notation of named complex data:
Examples
person {name:"Andrew" age:27}
collection{item{id:1 val:12} item{id:2 val:24} item{id:3 val:48}
person {
name: "Andrew"
age: 27
}
collection {
item {
id: 1
val: 12 }
item {
id: 2
val: 24}
item {
id: 3
val: 48}
person
name: "Matthew"
age: 27
collection
item
id: 1
val: 12
item
id: 2
val: 24
item
id: 3
val: 48
There are two pattern that used both in JSON and AXON. These are list (array in JSON) and dict (object in JSON).
Additional tuple is supposed to represent n-tuples of values: pairs, triples, quads, ... In contrast to list, tuple is a fixed ordered collection of values.
List represents a sequence of values. Just as list in Python, but without comma (','): values in the list are separeted by space characters (' ', '\t', '\n', '\r').
For example:
[]
[1 2 3]
["one"
"two"
"three"]
Dict represents an unordered collection of key : value pairs. Just as dict in python and associative array in javascript, but also without comma (','): key:value pairs in the dict are separeted by space characters Keys are always strings or identifiers.
For example:
{}
{"one":1 "two":2 "three":3}
{one: 1 two: 2 three: 3}
{
one: 1
two: 2
three: 3
}
Tuple represents n-tuples of values. Just like in python too, but without comma between values: values are separated by space characters. For example:
()
(1 2 3)
("one"
"two"
"three")
All named complex values has both expression based and statement based notation.
Node is an analog of XML Element in XML Infoset model.
For example:
# compact expression form
color {r:64 g:32 b:16}
# formatted expression form
color {
r: 64
g: 32
b: 16
}
# statement form
color
r: 64
g: 32
b: 16
In [ ]: