A JSON5 serializer and parser library for Python 3 written in Cython.
The serializer returns ASCII data that can safely be used in an HTML template. Apostrophes, ampersands, greater-than, and less-then signs are encoded as unicode escaped sequences. E.g. this snippet is safe for any and all input:
"<a onclick='alert(" + encode(data) + ")'>show message</a>"
Unless the input contains infinite or NaN values, the result will be valid JSON data.
You can find the full documentation online at https://pyjson5.readthedocs.io/en/latest/. Or simply call
The library supplies load(s) and dump(s) functions, so you can use it as a drop-in replacement for Python's builtin
json module, but you should use the functions
At least CPython 3.4 is needed. Other interpreters such as Pypy and older CPython versions are not supported and will not be supported.