Skip to main content

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/actions/workflow/status/renatahodovan/xson/main.yml?branch=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 and CLI-compatible with Python’s standard JSON package.

Requirements

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

Release files for xson 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xson 1.1.1
File Size Uploaded
xson-1.1.1.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xson 1.1.1
File Interpreter ABI Platform
xson-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.8 kB

Release files / xson-1.1.1.tar.gz

Download URL xson-1.1.1.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
27ccb5a63eb35c04ecf9668bcd6c0980b9284231246e284a1ce40f5df8d318a4
BLAKE2b-256 checksum
How to use checksums
e0da3184f5f22ce5edbe7647d44ebc3e3aa9f4fd70447e09f38c199ca33ff051
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / xson-1.1.1-py3-none-any.whl

Download URL xson-1.1.1-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c53a32c9379c58b4d69474e801e968dbafb010cb3dee393bc583896fe7e0383
BLAKE2b-256 checksum
How to use checksums
8981849af5bbadf53fc13c062000d71f0cc272b05ae53867fb794e255da948ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page