JSONXOX: Extended JSON Parsing
Do you love the JSON serialization format but wish it included support for optional comments and trailing commas? Well if so, the JSONXOX library is for you.
The JSONXOX library provides support for parsing extended JSON files and strings – JSON files and strings which may contain optional C-style single-line and multi-line comments as well as trailing commas.
Requirements
The JSONXOX library has been tested with Python 3.10, 3.11, 3.12, 3.13 and 3.14. The library has not been tested with, nor is it likely compatible with Python 3.9 and earlier.
Installation
The JSONXOX library is available from PyPI, so may be added to a project's dependencies
via its requirements.txt file or similar by referencing the JSONXOX library's name,
jsonxox, or the library may be installed directly into the local runtime environment
using pip install by running the following command:
$ pip install jsonxox
Usage Example
To use the JSONXOX library, simply import the library into your project as a drop-in
replacement for the standard json library, and use it as you would to load a JSON file
or JSON string. The library can be used to load standard JSON files and strings as well
as extended JSON files and strings containing single- and multi-line comments as well as
trailing commas. The library can also be used to save standard JSON files and strings.
See the Methods section for more information about the methods provided by the library.
import jsonxox
sample: str = """
/* this is a multi-line comment block
that can span multiple lines or just a single line
*/
{
"a": 123, /* this is also a multi-line comment block (using a single line) */
// this is a single-line comment
"b": "456", // notice the trailing comma
}
"""
data = jsonxox.loads(sample)
assert isinstance(data, dict)
assert "a" in data
assert data["a"] == 123
assert "b" in data
assert data["b"] == "456"
Methods
The jsonxox library provides the following methods, mirroring the standard json
library in its available methods and overall functionality:
-
load(handle, **kwargs)(object) – Theload()method takes a file handle or file handle like object that is an instance ofio.TextIOWrapperor one of its subclasses as input and removes any single and multi-line comments as well as any trailing commas from the input string contents read from the file handle, and then passes the cleaned string to the standard library'sjson.loads()method for quick deserialization to its corresponding Python data types. Any additional keyword arguments are passed to thejson.loads()method, as such any additional keyword arguments must be compatible with thejson.loads()method. -
loads(handle, **kwargs)(object) – Theloads()method takes a string as input and removes any single and multi-line comments as well as any trailing commas from the input string, and then passes the cleaned string to the standard library'sjson.loads()method for quick deserialization to its corresponding Python data types. Any additional keyword arguments are passed to thejson.loads()method, as such any additional keyword arguments must be compatible with thejson.loads()method -
dump(*args, **kwargs)– Thedump()method is a passthrough to the standardjsonlibrary'sdump()method and accepts the same arguments and has the same return values. Note that thedump()method cannot be used to re-save any comments or trailing commas that may have been present in the original extended JSON file or string. -
dumps(*args, **kwargs)(str) – Thedumps()method is a passthrough to the standardjsonlibrary'sdumps()method and accepts the same arguments and has the same return values. Note that thedumps()method cannot be used to re-save any comments or trailing commas that may have been present in the original extended JSON file or string.
Classes
The jsonxox library provides the following classes, mirroring the standard json
library in its available classes:
-
JSONDecoder– TheJSONDecoderclass is a direct import of and reference to the standardjsonlibrary'sJSONDecoderclass. -
JSONEncoder– TheJSONEncoderclass is a direct import of and reference to the standardjsonlibrary'sJSONEncoderclass.
Exceptions
The jsonxox library provides the following exception classes, mirroring the standard
json library in its available exception classes:
-
JSONDecodeError– TheJSONDecodeErrorexception class is a direct import of and reference to the standardjsonlibrary'sJSONDecodeErrorexception class. -
JSONXOXDecodeError– TheJSONXOXDecodeErrorexception class is a subclass of the standardjsonlibrary'sJSONDecodeErrorclass and will be raised by thejsonxoxlibrary if an exception occurs while attempting to clean or load the JSON input.
Unit Tests
The JSONXOX library includes a suite of comprehensive unit tests which ensure that the
library functionality operates as expected. The unit tests were developed with and are
run via pytest.
To ensure that the unit tests are run within a predictable runtime environment where all
of the necessary dependencies are available, a Docker image is
created within which the tests are run. To run the unit tests, ensure Docker and Docker
Compose is installed, and perform the
following commands, which will build the Docker image via docker compose build and
then run the tests via docker compose run – the output the tests will be displayed:
$ docker compose build
$ docker compose run tests
To run the unit tests with optional command line arguments being passed to pytest,
append the relevant arguments to the docker compose run tests command, as follows, for
example passing -v to enable verbose output and -s to print standard output:
$ docker compose run tests -v -s
See the documentation for PyTest regarding available optional command line arguments.
Copyright & License Information
Copyright © 2023–2026 Daniel Sissman; licensed under the MIT License.
Metadata
Release files for jsonxox 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsonxox-0.8.0.tar.gz | 8.5 kB | With provenance | Details for jsonxox-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsonxox-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for jsonxox-0.8.0-py3-none-any.whl |
Total release size: 14.2 kB
Release files / jsonxox-0.8.0.tar.gz
| Download URL | jsonxox-0.8.0.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
583ed7d23267df560c452ccfe0227419bfffb220745f9f4d64503a9320db925c
|
|
BLAKE2b-256 checksum How to use checksums |
bb8dd36efff95bb95bc3bdbe92d8795e735642acff2a78e82e2961ecc8d8d5e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 12, 2026.
Transparency logRelease files / jsonxox-0.8.0-py3-none-any.whl
| Download URL | jsonxox-0.8.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d2cb361938509e239ae3bed2b9dfa54b82bcd92cab5c438652a6664c32fe92e2
|
|
BLAKE2b-256 checksum How to use checksums |
9790ced5437f827049e8443cb10b105e0ffde84a0445e5bc55544488f425ba4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 12, 2026.
Transparency logSecurity for jsonxox 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for jsonxox-0.8.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.