A wrapper to JSON parsers allowing comments, multiline strings and trailing commas
Python 2.7, 3.3
ujson 1.30+
JSON Comment allows to parse JSON files or strings with:
This package works with any JSON parser which supports:
load(fp, ...)
to parse filesloads(s, ...)
to parse stringsby adding a preprocessor to these calls.
#
and ;
are for single line comments/*
and */
enclose multiline commentsInline comments are not supported
Any string can be multiline, even object keys.
"""
, like in python\\n
pip install jsoncomment
OR
python setup.py install
import json
from jsoncomment import JsonComment
string = "[]"
parser = JsonComment(json)
parsed_object = parser.loads(string)
Added in the /examples directory
#
, ;
and /*
may be preceded only by whitespaces or tabs on the same line*/
may be followed only by whitespaces or tabs on the same lineSource code available with MIT license on Bitbucket.
Added in top level __init__.py
API is split in:
* `User Interface` for common use
* `Developer Interface` exposing some internals that could be useful
For each item ( function or class ), there are 2 blocks of comments, above and below item definition:
* The top describes the return values
* The bottom describes the item and call variables
If call variables have defaults or use duck typing, every allowed value is described
Example:
# return_value
# description
from .some_module import SomeClass
# SomeClass description
# (
# variable_1,
# description
# variable_2 = something,
# description
# = Default
# description of default value ( something )
# = something_2
# description of alternate form ( duck typing )
# )
describes return_value = SomeClass(variable_1, variable_2 = current_value)
Dando Real ITA @ Steam Profile