There is AXON (textual) format that combine the best of JSON, XML and YAML.
AXON format is quite readable and relatively compact.
The python (2.7/3.3-3.7) module pyaxon supports load(s)
/dump(s)
functionality, including iterative loading
/dumping
. It's sufficiently fast in order to be useful.
Consider simple example:
>>> d = {
'age': 27, 'name': 'Joe',
'numbers': [1, 2, 3, 4, 5],
'subdict': {'first': 1, 'second': 2, 'third': 3}
}
# pretty form
>>> axon.dumps(d, pretty=1)
{ age: 27
name: "Joe"
numbers: [1 2 3 4 5]
subdict: {
first: 1
second: 2
third: 3}}
# compact form
>>> axon.dumps(d)
{age:27 name:"Joe" numbers:[1 2 3 4 5] subdict:{first:1 second:2 third:3}}
It also can handle multiple objects in the message:
>>> msg = axon.dumps([{'a':1, 'b':2, 'c':3}, {'a':2, 'b':3, 'c':4}])
>>> print(msg)
{a:1 b:2 c:3}
{a:2 b:3 c:4}
{a:3 b:4 c:5}
and then load them iteratively:
for d in axon.iloads(msg):
print(d)