Skip to main content

XSON: XML Encoding for JSON

Project description

XML Encoding for JSON

https://badge.fury.io/py/xson.svg https://travis-ci.org/renatahodovan/xson.svg?branch=master https://coveralls.io/repos/github/renatahodovan/xson/badge.svg?branch=master

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-compatible with Python’s standard JSON package.

Requirements

  • Python >= 3.4
  • pip and setuptools Python packages (the latter is automatically installed by pip)

Install

The quick way:

pip install xson

Alternatively, by cloning the project and running setuptools:

python setup.py install

Usage

Example:

>>> import xson
>>> out = xson.dumps({'foo': 42, 'bar': [3.14, 'baz', True, None]}, indent=4)
>>> print(out)
<?xml version="1.0" encoding="UTF-8"?>
<json:object xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx">
    <json:number name="foo">42</json:number>
    <json:array name="bar">
        <json:number>3.14</json:number>
        <json:string>baz</json:string>
        <json:boolean>true</json:boolean>
        <json:null/>
    </json:array>
</json:object>

>>> dct = xson.loads(out)
>>> print(dct)
{'foo': 42, 'bar': [3.14, 'baz', True, None]}

Project details


Download files

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

Files for xson, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size xson-1.0.1.tar.gz (12.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page