Skip to main content

A JSON5 parser that, among other features, supports round-trip preservation of comments

Project description

# json-five

JSON5 for Python

## Installation

` pip install json-five `

## Usage

NOTE: the import name is different from the install name (sorry, many were taken already)

`python >>> import json5 >>> json_text = """{ // This is a JSON5 comment "foo": "bar" /* this is a JSON5 block comment that can span lines /* "bacon": "eggs" } """ >>> json5.loads(json_text) {"foo": "bar", "bacon": "eggs"} `

## Project goals

  • support a similar interface to the json module with support for JSON5 sources

  • support round-trip preservation of comments

## Status/milestones

This project is in very early stages of development. The following are some milestones that hopefully will be able to be marked as done as development progresses.

  • [x] parse json5 to Python (ignoring comments) - [x] line comments - [x] block comments - [x] numeric literals - [x] trailing commas for arrays and objects - [x] line continuations - [x] ecma identifiers as object keys - [x] leading plus for numbers - [x] single quoted strings - [x] escape characters in strings

  • [ ] dump python to JSON (no comment support) - [x] indent style (that matches json) - [ ] style options (quotes, trailing commas, etc) - [ ] helper classes for dumping types as other literals (hexadecimal numbers, identifiers, etc) - [ ] support similar options to json (e.g. object_hook, parse_x, strict, ensure_ascii, etc) - [ ] string escapes according to quote style

  • [ ] support manipulation of json model (e.g. to add/edit comments)

  • [ ] dump json model with comments

  • [ ] preserve comments when loading json5 (round-trip support)

  • [ ] Optimize with a C/Cython version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

json-five-0.0.2.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

json_five-0.0.2-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file json-five-0.0.2.tar.gz.

File metadata

  • Download URL: json-five-0.0.2.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for json-five-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f6eb3dc533a024c53c2864f5ee296e88622c6a067fd0645abe9233b2e44f29c0
MD5 0c6a4045a454301018ff657ff17f2171
BLAKE2b-256 947aa11767cb27e86502047f72fe680c0c06233055860d6b5d4a95dfcbe518fb

See more details on using hashes here.

Provenance

File details

Details for the file json_five-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: json_five-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for json_five-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c01fd94fd9abc5aa5e56810ebcbd58706a6b04559eeacb124399247542a95942
MD5 2a928c50bdf236ef615de0c86d2ac492
BLAKE2b-256 92980c58d0ff9248b778d0f9ddc380423e970230ae69bf1cd633f88a8941e1a8

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page