<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 AXON
Step1:  JSON is subset of AXON
Here is well known example of JSON message
Step2:  One can see that content of json_vals and axon_vals are equal.
Step3:  AXON supports more readable and compact form. Any JSON message can be translated to this form by removing of all , and " around keys that are identifiers
Step4:  We'l call these forms as JSON style of notation, which bases on compositions of dicts and lists.
For compatibility reasons there is a mode in pyaxon python library that allow using symbol ',' as a separator symbol between values in lists and dicts. In this case almost valid JSON message can be loaded as well as AXON message
Step5:  There is compact dump
Step6:  There is a dump into formatted form
Step7:  There is also parameter hsize. It specifies maximum number of simple data items in a line
Step8:  AXON also supports  reference links between values in the message. Here is an simple example
Step9:  AXON extends JSON and makes things that XML can
Mapping as sort of named JSON object
Let's consider short fragment of JSON
Step10:  Here is it's XML version for comparison
Step11:  Compact form of notation usually as small as many binary serialization formats in the cases when objects contains mostly strings and a few of numbers. 
Formatted form is used for readability of expresson based format of representation
Step12:  Note that one free to use spaces and line breaks between tokens as he want. 
AXON also supports YAML/Python inspired formatted form without braces
<ASSISTANT_TASK:>
Python Code:
from __future__ import unicode_literals, print_function, division
from pprint import pprint
import axon
import json
import xml.etree as etree
from IPython.display import HTML, display, display_html
Explanation: AXON: Tutorial
Let's import inventory for playing with AXON with python.
End of explanation
!cat basic_sample.json
json_vals= json.load(open("basic_sample.json"))
vals = axon.load("basic_sample.json", json=1)
Explanation: JSON is subset of AXON
Here is well known example of JSON message:
End of explanation
print(json_vals)
print(vals[0])
assert str(json_vals) == str(vals[0])
Explanation: One can see that content of json_vals and axon_vals are equal.
End of explanation
axon.dumps(vals, pretty=1))
Explanation: AXON supports more readable and compact form. Any JSON message can be translated to this form by removing of all , and " around keys that are identifiers:
End of explanation
!cat better_json.axon
vals = axon.load("better_json.axon")
pprint(vals)
Explanation: We'l call these forms as JSON style of notation, which bases on compositions of dicts and lists.
For compatibility reasons there is a mode in pyaxon python library that allow using symbol ',' as a separator symbol between values in lists and dicts. In this case almost valid JSON message can be loaded as well as AXON message:
AXON as better JSON
AXON supports decimal numbers, date/time/datetime values and comments.
Let's consider AXON example &ndash; list of dicts containing decimal, date and time values:
End of explanation
print(axon.dumps(vals))
Explanation: There is compact dump:
End of explanation
print(axon.dumps(vals, pretty=1))
Explanation: There is a dump into formatted form:
End of explanation
print(axon.dumps(vals, pretty=1, hsize=2))
Explanation: There is also parameter hsize. It specifies maximum number of simple data items in a line:
End of explanation
!cat better_json_crossref.axon
vals = axon.load("better_json_crossref.axon")
assert vals[-1]['children'][0] is vals[0]
assert vals[-1]['children'][1] is vals[1]
pprint(vals)
print(axon.dumps(vals, pretty=1, crossref=1, hsize=2))
Explanation: AXON also supports  reference links between values in the message. Here is an simple example:
End of explanation
vals = axon.load("basic_sample.axon")
print(axon.dumps(vals, pretty=1))
Explanation: AXON extends JSON and makes things that XML can
Mapping as sort of named JSON object
Let's consider short fragment of JSON:
json
"name": {
    "key_1": "value_1", 
    "key_2": "value_2"
}    
It can be translated as a value of the attribute name of some object. But it also can be translated as an object that is constructed from the value 
json
{
    "key_1": "value_1", 
    "key_2": "value_2"
}
using some factory function that corresponds to the tag name.
For this kind of use cases there are mappings in AXON:
javascript
name {
    key_1: "value_1" 
    key_2: "value_2"
}    
It's also usefull for notation of the object whose type/class is mapped to the name.
This kind of notation may be also considered as direct translation of the XML notation:
xml
&lt;name 
    key_1="value_1"
    key_2="value_2" /&gt;
Sequence as a sort of named JSON array
Let's consider another short fragment of JSON:
json
"name": [
    «value_1»,
    «value_2»
]
Some times this form is used for notation of the container of some type that corresponds to the tag name.
For this kind of use cases there are sequences in AXON:
javascript
tag {
    «value_1»
    «value_2»
}
This kind of notation in AXON can be considered as translation of the following XML pattern:
xml
&lt;tag&gt;
    «value_1»
    «value_2»
&lt;/tag&gt;
AXON and XML
First basic example of JSON can be translated to AXON by following XML style of data representation when anonymous structures becames named and subelement is used instead of key:value or attribute:value value for some good reasons:
End of explanation
print(axon.dumps(vals))
Explanation: Here is it's XML version for comparison:
&lt;person firstName="John" lastName="Smith" age="25"&gt;
    &lt;address 
        streetAddress="21 2nd Street" 
        city="New York"
        state="NY"
        postalCode=10021 /&gt;
    &lt;phoneNumber type="home" number="212 555-1234"/&gt;
    &lt;phoneNumber type="fax" number="646 555-4567"/&gt;
&lt;/person&gt;
By this way one can support extensibility of the representation as XML does when element is used instead of attribute. In case of XML this kind of notation is verbose for representation of name/value pair:
&lt;attr&gt;value&lt;/attr&gt;
But in case of AXON it isn't:
attr{value}
So any XML element 
xml
&lt;ename
  attr_1="value_m"
  ...
  attr_m="value_m"&gt;
  &lt;subename_1&gt;...&lt;/subename_1&gt;
  ...
  &lt;subename_N&gt;...&lt;/subename_N&gt;
&lt;/ename&gt;
can be easily translated to AXON notation as follows:
``` javascript
ename {
  attr_1:"value_m"
  ...
  attr_m:"value_m"
  subename_1 {...}
  ...
  subename_N {...}
}
```
AXON formatting with/without braces
Presented above AXON forms of messages are are in compact form and in formatted with braces.
Compact form uses minimum amount of space:
End of explanation
print(axon.dumps(vals, pretty=1, braces=1))
Explanation: Compact form of notation usually as small as many binary serialization formats in the cases when objects contains mostly strings and a few of numbers. 
Formatted form is used for readability of expresson based format of representation:
End of explanation
print(axon.dumps(vals, pretty=1))
Explanation: Note that one free to use spaces and line breaks between tokens as he want. 
AXON also supports YAML/Python inspired formatted form without braces:
End of explanation
<END_TASK>