Skip to main content

A wrapper to JSON parsers allowing comments and multiline strings

Project description

A wrapper to JSON parsers allowing comments and multiline strings


Dependencies

Python 2.7, 3.3

Optional

ujson 1.30+


Description

JSON Comment allows to parse JSON files or strings with:

  • Single and Multi line comments
  • Multi line data strings

This package works with any JSON parser which supports:

  • load(fp, ...) to parse files
  • loads(s, ...) to parse strings

by adding a preprocessor to these calls.


Comments

  • # and ; are for single line comments
  • /* and */ enclose multiline comments

Inline comments are not supported


Multiline strings

Any string can be multiline, even object keys.

  • Multiline strings start and end with """, like in python
  • The preprocessor merges all lines to a single standard string
  • A single trailing space is kept, if present
  • New line is not kept. To hard code new lines in the string, use \\n

Usage

Install

pip install jsoncomment

OR

  • Download source
  • python setup.py install

Call Example

import json
from jsoncomment import JsonComment

string = "[]"
parser = JsonComment(json)
parsed_object = parser.loads(string)

Examples

Added in the /examples directory


Source

Source code available with MIT license on Bitbucket.


Contact

Dando Real ITA @ Steam Profile

Project details


Download files

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

Files for jsoncomment, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size jsoncomment-0.2.2.win32.exe (206.2 kB) File type Windows Installer Python version any Upload date Hashes View
Filename, size jsoncomment-0.2.2.win-amd64.exe (232.3 kB) File type Windows Installer Python version any Upload date Hashes View
Filename, size jsoncomment-0.2.2.zip (8.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page