Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wbolster/jsonx

Python library for JSONx, an XML representation of the JSON data model
https://github.com/wbolster/jsonx

Last synced: about 2 months ago
JSON representation

Python library for JSONx, an XML representation of the JSON data model

Awesome Lists containing this project

README

        

=====
JSONx
=====

This is a Python module implementing JSONx, an XML representation of the JSON
data model. The format is defined by IBM, and documentation is available on the
IBM website: `JSONx conversion rules
`_

Note: currently only writing support has been implemented; there's no parser
yet!

Example
=======

JSON:

.. code-block:: json

{"foo": [1, "bar", []]}

JSONx:

.. code-block:: xml




1
bar


WHAT? WHY WOULD I NEED THIS?
============================

You probably don't want to use this. But, hey, remember, using XML makes your
product ready for the enterprise!

Installation
============

Install using ``pip``::

pip install jsonx

Usage
=====

The interface mimics the familiar `json` module::

import jsonx

obj = {
"name": "John Doe",
"age": 12,
}

# To obtain a byte string, use dumps()
value = jsonx.dumps(obj)

# To write directly to a file-like object, use dump()
with open("output.xml") as fp:
jsonx.dump(obj, fp)