Skip to content

nineteendo/jsonyx

Repository files navigation

jsonyx

pypi conda-forge python license pytest docs downloads

jsonyx is a customizable JSON library for Python 3.8+. It is written in pure Python with an optional C extension for better performance and no dependencies.

Key Features

  • JSON encoding, decoding and patching:
    >>> import jsonyx as json
    >>> json.dumps(["foo", {"bar": ("baz", None, 1.0, 2)}])
    '["foo", {"bar": ["baz", null, 1.0, 2]}]\n'
    >>> json.loads('{"foo": ["bar", null, 1.0, 2]}')
    {'foo': ['bar', None, 1.0, 2]}
    >>> json.apply_patch([1, 2, 3], {"op": "del", "path": "$[1]"})
    [1, 3]
  • Pretty printing:
    {
        "foo": [1, 2, 3],
        "bar": {"a": 1, "b": 2, "c": 3}
    }
  • Optionally supports these JSON deviations (specified in the documentation):
    {
        /* Block */ // and line comments
        "Missing commas": [1 2 3],
        "NaN and infinity": [NaN, Infinity, -Infinity],
        "Surrogates": "\ud800",
        "Trailing comma": [0,],
        "Unquoted keys": {key: "value"}
    }
  • Detailed error messages:
    Traceback (most recent call last):
      File "/Users/wannes/Downloads/broken.json", line 1, column 99-381
        ...sList": {"GlossEntry": {"ID": "SGM..."GML", "XML"]}, "GlossSee": "markup"
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    jsonyx.JSONSyntaxError: Unterminated object
    

The documentation for jsonyx is available online at: https://jsonyx.readthedocs.io

Sponsor this project

Contributors 8