Skip to main content

XSON: XML Encoding for JSON

Project description

XML Encoding for JSON

XSON is a Python package that supports the serialization of Python objects to XML documents according to the JSONx specification (draft), as well as the deserialization of JSONx documents to Python objects. The implementation aims at being API and CLI-compatible with Python’s standard JSON package.



To use XSON in another project, it can be added to setup.cfg as an install requirement (if using setuptools with declarative config):

install_requires =

To install XSON manually, e.g., into a virtual environment, use pip:

pip install xson

The above approaches install the latest release of XSON from PyPI. Alternatively, for the development version, clone the project and perform a local install:

pip install .




>>> import xson
>>> out = xson.dumps({'foo': 42, 'bar': [3.14, 'baz', True, None]}, indent=4)
>>> print(out)  #doctest: +NORMALIZE_WHITESPACE
<?xml version="1.0" encoding="UTF-8"?>
<json:object xmlns:json="">
    <json:number name="foo">42</json:number>
    <json:array name="bar">
>>> dct = xson.loads(out)
>>> print(dct)
{'foo': 42, 'bar': [3.14, 'baz', True, None]}


A command line tool is available to validate, pretty-print, or convert between JSONx and JSON objects:

xson-tool --help


python -m xson.tool --help

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xson-1.1.0.tar.gz (18.0 kB view hashes)

Uploaded Source

Built Distribution

xson-1.1.0-py3-none-any.whl (9.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page