Skip to content

VincentM/xon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

xon

xon is a Python implementation of something I've come to call "XML Object Notation", or XON. It generally conforms to the pickle protocol, which means you interact with it using load and dump functions.

XON arose out of a need to support XML in web-based APIs that already support JSON, and supports the same vocabulary that JSON does. It is based on--and, in fact, the test cases come from--Stefan Goessner's "Converting Between XML and JSON". If you don't use any of xon's extra options, it is intended to work exactly like Goessner describes therein:

>>> import xon
>>> xon.dumps({'foo': {'bar': ['baz', 'quux']}})
'<foo><bar>baz</bar><bar>quux</bar></foo>'
>>> xon.loads('<foo><bar>baz</bar><bar>quux</bar></foo>')
{'foo': {'bar': ['baz', 'quux']}}

Additional options include convertvalues, which will convert ints, floats, and bools in addition to the default behavior of handling strings only, and wrap/unwrap, which deals with the root tag so that the load result and dump parameters are more like typical JSON objects.

About

XML Object Notation serializer/deserializer

Resources

Stars

Watchers

Forks

Packages

No packages published