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.
Requirements
Python >= 3.5
Install
To use XSON in another project, it can be added to setup.cfg as an install requirement (if using setuptools with declarative config):
[options]
install_requires =
xson
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 .
Usage
API
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]}
CLI
A command line tool is available to validate, pretty-print, or convert between JSONx and JSON objects:
xson-tool --help
or:
python -m xson.tool --help
Copyright and Licensing
Licensed under the BSD 3-Clause License.
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
Built Distribution
File details
Details for the file xson-1.1.0.tar.gz
.
File metadata
- Download URL: xson-1.1.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf0b5c71857cd25314945518a747dc5b75ce6e655db6124413f31b50ca2455f3 |
|
MD5 | 10dc58ae41f0c7b3b6becaff74761002 |
|
BLAKE2b-256 | 9feea15a947d2a07ff1ba2bc23e958ab427555cb8782b1743ce3213c302e6b8c |
File details
Details for the file xson-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: xson-1.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31fae39f4dbca32aea85c7f454842382e502110ed0831eb51a2bd8a2bbbb183e |
|
MD5 | e1cdc7c76c655d75cdc6a281a17ba327 |
|
BLAKE2b-256 | accd7faa2ae56d1cb93a7386f194623a0f4a2838c8c9197185960f7557df972a |