A Python implementation of the JSON5 data format.
Project description
pyjson5
A Python implementation of the JSON5 data format.
JSON5 extends the JSON data interchange format to make it slightly more usable as a configuration language:
-
JavaScript-style comments (both single and multi-line) are legal.
-
Object keys may be unquoted if they are legal ECMAScript identifiers
-
Objects and arrays may end with trailing commas.
-
Strings can be single-quoted, and multi-line string literals are allowed.
There are a few other more minor extensions to JSON; see the above page for the full details.
This project implements a reader and writer implementation for Python; where possible, it mirrors the standard Python JSON API package for ease of use.
This is an early release. It has been reasonably well-tested, but it is SLOW. It can be 1000-6000x slower than the C-optimized JSON module, and is 200x slower (or more) than the pure Python JSON module.
Known issues
-
Did I mention that it is SLOW?
-
The implementation follows Python3's
jsonimplementation where possible. This means that theencodingmethod todump()is ignored, and unicode strings are always returned. -
The
clskeyword argument thatjson.load()/json.loads()accepts to specify a custom subclass ofJSONDecoderis not and will not be supported, because this implementation uses a completely different approach to parsing strings and doesn't have anything like theJSONDecoderclass. -
The
clskeyword argument thatjson.dump()/json.dumps()accepts is also not supported, for consistency withjson5.load(). Thedefaultkeyword is supported, though, and might be able to serve as a workaround.
Version History / Release Notes
-
v0.8.2 (2019-06-11)
- Actually bump the version properly, to 0.8.2.
-
v0.8.1 (2019-06-11)
- Fix bug in setup.py that messed up the description. Unfortunately, I forgot to bump the version for this, so this also identifies as 0.8.0.
-
v0.8.0 (2019-06-11)
- Add
allow_duplicate_keys=Trueas a default argument tojson5.load()/json5.loads(). If you set the key toFalse, duplicate keys in a single dict will be rejected. The default is set toTruefor compatibility withjson.load(), earlier versions of json5, and because it's simply not clear if people would want duplicate checking enabled by default.
- Add
-
v0.7 (2019-03-31)
- Changes dump()/dumps() to not quote object keys by default if they are
legal identifiers. Passing
quote_keys=Truewill turn that off and always quote object keys. - Changes dump()/dumps() to insert trailing commas after the last item
in an array or an object if the object is printed across multiple lines
(i.e., if
indentis not None). Passingtrailing_commas=Falsewill turn that off. - The
json5.toolcommand line tool now supports the--indent,--[no-]quote-keys, and--[no-]trailing-commasflags to allow for more control over the output, in addition to the existing--as-jsonflag. - The
json5.toolcommand line tool no longer supports reading from multiple files, you can now only read from a single file or from standard input. - The implementation no longer relies on the standard
jsonmodule for anything. The output should still match the json module (except as noted above) and discrepancies should be reported as bugs.
- Changes dump()/dumps() to not quote object keys by default if they are
legal identifiers. Passing
-
v0.6.2 (2019-03-08)
- Fix GitHub issue #23 and pass through unrecognized escape sequences.
-
v0.6.1 (2018-05-22)
- Cleaned up a couple minor nits in the package.
-
v0.6.0 (2017-11-28)
- First implementation that attempted to implement 100% of the spec.
-
v0.5.0 (2017-09-04)
- First implementation that supported the full set of kwargs that
the
jsonmodule supports.
- First implementation that supported the full set of kwargs that
the
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json5-0.8.2.tar.gz.
File metadata
- Download URL: json5-0.8.2.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63a56bb02d973eec72b704bb383172241392115635b51ce1c60f9141ad71294a
|
|
| MD5 |
2dbbe528e7517eb3cf7bde9a72b3a449
|
|
| BLAKE2b-256 |
f5e89f58f04b5afdd9f6d94efd021a61036012f5386397e1ec699a481f8e2304
|
File details
Details for the file json5-0.8.2-py2.py3-none-any.whl.
File metadata
- Download URL: json5-0.8.2-py2.py3-none-any.whl
- Upload date:
- Size: 29.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0bb21f90e126071b64a0515583b1c9289bcdc66874276e4052d733df5e6d94f
|
|
| MD5 |
6d835c5ca5a4029e2c57ce3932ef24b1
|
|
| BLAKE2b-256 |
802bc3681e7341afe9ef620e9018b7d01eb2c27c15e67d2811e0c0c149582b22
|