Skip to main content

XSON: XML Encoding for JSON

Project description

XML Encoding for JSON

https://img.shields.io/pypi/v/xson?logo=python&logoColor=white https://img.shields.io/pypi/l/xson?logo=open-source-initiative&logoColor=white https://img.shields.io/github/workflow/status/renatahodovan/xson/main/master?logo=github&logoColor=white https://img.shields.io/coveralls/github/renatahodovan/xson/master?logo=coveralls&logoColor=white

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.5

  • 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)  #doctest: +NORMALIZE_WHITESPACE
<?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.

Source Distribution

xson-1.0.3.tar.gz (16.0 kB view details)

Uploaded Source

File details

Details for the file xson-1.0.3.tar.gz.

File metadata

  • Download URL: xson-1.0.3.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

File hashes

Hashes for xson-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e64e1c047e6c32cf333e5a766dde2a73e508d20411eaa2f4924466a6e8313f8b
MD5 2b0950248757dfad4003af350b8d4946
BLAKE2b-256 464ad5016d65b976ff520aa06589992ee07674201ceeffb67dcf970b75b94bb3

See more details on using hashes here.

Supported by

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