jsoncomment


Namejsoncomment JSON
Version 0.4.2 PyPI version JSON
download
home_pagehttps://bitbucket.org/Dando_Real_ITA/json-comment
SummaryA wrapper to JSON parsers allowing comments, multiline strings and trailing commas
upload_time2019-02-08 00:15:14
maintainer
docs_urlNone
authorGaspare Iengo
requires_python>=3.3
licenseMIT
keywords json comments multiline
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Json Comment
============

A wrapper to JSON parsers allowing comments, multiline strings and trailing commas

- - -

Dependencies
------------

* Python 3.3+
* TODO NEW ADDITIONS

### Optional

* ujson 1.30+

- - -

Description
-----------

JSON Comment allows to parse JSON files or strings with:

* Single and Multi line comments
* Multi line data strings
* Trailing commas in objects and arrays, after the last item

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 JSON standard string
* A single trailing space per line is kept, if present
* New line is not kept. To hard code new lines in the string, use `\\n`

- - -

Custom Methods
--------------

### File Load

`loadf(path, *args, default = None, **kwargs)`

Opens a JSON file with comments. Allows a default value if loading or parsing fails

### File Save

`dumpf(json_obj, path, *args, indent=4, **kwargs)`

Saves a JSON file with indentation

- - -

Install
-------

`pip install jsoncomment`

OR

* Download source
* `python setup.py install`

- - -

Usage
-----

	from jsoncomment import JsonComment

	string = "[]"
	json = JsonComment()
	json_obj = json.loads(string)

### Examples

Added in the /examples directory

- - -

### Limitations

* `#`, `;`, `//` and `/*` may be preceded only by whitespaces or tabs on the same line
* `*/` may be followed only by whitespaces or tabs on the same line
* The trailing comma must be the last character on the same line

- - -

Source
------

[Source](https://bitbucket.org/Dando_Real_ITA/json-comment/src/default)
code available with MIT license on Bitbucket.

- - -

API
---

Added in top level `__init__.py`

### How to read the API

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)`

- - -

Contact
-------

Gaspare Iengo @ [email](mailto:gaspareiengo@gmail.com)



            

Raw data

            {
    "_id": null,
    "home_page": "https://bitbucket.org/Dando_Real_ITA/json-comment",
    "name": "jsoncomment",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.3",
    "maintainer_email": "",
    "keywords": "json comments multiline",
    "author": "Gaspare Iengo",
    "author_email": "gaspareiengo@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c3/75/b5c7895b8d2edcecbc49b55adb10087183050f95eac33c3453cc12c610f1/jsoncomment-0.4.2.tar.gz",
    "platform": "",
    "description": "Json Comment\n============\n\nA wrapper to JSON parsers allowing comments, multiline strings and trailing commas\n\n- - -\n\nDependencies\n------------\n\n* Python 3.3+\n* TODO NEW ADDITIONS\n\n### Optional\n\n* ujson 1.30+\n\n- - -\n\nDescription\n-----------\n\nJSON Comment allows to parse JSON files or strings with:\n\n* Single and Multi line comments\n* Multi line data strings\n* Trailing commas in objects and arrays, after the last item\n\nThis package works with any JSON parser which supports:\n\n* `load(fp, ...)` to parse files\n* `loads(s, ...)` to parse strings\n\nby adding a preprocessor to these calls.\n\n- - -\n\n### Comments\n\n* `#`, `;` and `//` are for single line comments\n* `/*` and `*/` enclose multiline comments\n\nInline comments are **not** supported\n\n- - -\n\n### Multiline strings\n\nAny string can be multiline, even object keys.\n\n* Multiline strings start and end with `\"\"\"`, like in python\n* The preprocessor merges all lines to a single JSON standard string\n* A single trailing space per line is kept, if present\n* New line is not kept. To hard code new lines in the string, use `\\\\n`\n\n- - -\n\nCustom Methods\n--------------\n\n### File Load\n\n`loadf(path, *args, default = None, **kwargs)`\n\nOpens a JSON file with comments. Allows a default value if loading or parsing fails\n\n### File Save\n\n`dumpf(json_obj, path, *args, indent=4, **kwargs)`\n\nSaves a JSON file with indentation\n\n- - -\n\nInstall\n-------\n\n`pip install jsoncomment`\n\nOR\n\n* Download source\n* `python setup.py install`\n\n- - -\n\nUsage\n-----\n\n\tfrom jsoncomment import JsonComment\n\n\tstring = \"[]\"\n\tjson = JsonComment()\n\tjson_obj = json.loads(string)\n\n### Examples\n\nAdded in the /examples directory\n\n- - -\n\n### Limitations\n\n* `#`, `;`, `//` and `/*` may be preceded only by whitespaces or tabs on the same line\n* `*/` may be followed only by whitespaces or tabs on the same line\n* The trailing comma must be the last character on the same line\n\n- - -\n\nSource\n------\n\n[Source](https://bitbucket.org/Dando_Real_ITA/json-comment/src/default)\ncode available with MIT license on Bitbucket.\n\n- - -\n\nAPI\n---\n\nAdded in top level `__init__.py`\n\n### How to read the API\n\nAPI is split in:\n\n\t* `User Interface` for common use\n\t* `Developer Interface` exposing some internals that could be useful\n\nFor each item ( function or class ), there are 2 blocks of comments, above and below item definition:\n\n\t* The top describes the return values\n\t* The bottom describes the item and call variables\n\nIf call variables have defaults or use duck typing, every allowed value is described\n\nExample:\n\n\t# return_value\n\t\t# description\n\tfrom .some_module import SomeClass\n\t\t# SomeClass description\n\t# (\n\t\t# variable_1,\n\t\t\t# description\n\t\t# variable_2 = something,\n\t\t\t# description\n\n\t\t\t# = Default\n\t\t\t\t# description of default value ( something )\n\t\t\t# = something_2\n\t\t\t\t# description of alternate form ( duck typing )\n\t# )\n\ndescribes `return_value = SomeClass(variable_1, variable_2 = current_value)`\n\n- - -\n\nContact\n-------\n\nGaspare Iengo @ [email](mailto:gaspareiengo@gmail.com)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A wrapper to JSON parsers allowing comments, multiline strings and trailing commas",
    "version": "0.4.2",
    "split_keywords": [
        "json",
        "comments",
        "multiline"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "139eec3da1601c7a5700e9e4229d5404e590107a1bbe50c78dbcfb33948177fc",
                "md5": "4248b5531144b1d4a8e83a448255e744",
                "sha256": "7ce82b755e54fdc0dc1c3c05e2bc7db0c3f609be31771401f78f00e743b0403e"
            },
            "downloads": -1,
            "filename": "jsoncomment-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4248b5531144b1d4a8e83a448255e744",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.3",
            "size": 6846,
            "upload_time": "2019-02-08T00:15:13",
            "upload_time_iso_8601": "2019-02-08T00:15:13.569846Z",
            "url": "https://files.pythonhosted.org/packages/13/9e/ec3da1601c7a5700e9e4229d5404e590107a1bbe50c78dbcfb33948177fc/jsoncomment-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c375b5c7895b8d2edcecbc49b55adb10087183050f95eac33c3453cc12c610f1",
                "md5": "4c8c19f965102b41e36f3d69c020e0fc",
                "sha256": "8fa065a85327306211ec567bb9ad8ca252c59332f6c6cf09c3228a0abf1191da"
            },
            "downloads": -1,
            "filename": "jsoncomment-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "4c8c19f965102b41e36f3d69c020e0fc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.3",
            "size": 9179,
            "upload_time": "2019-02-08T00:15:14",
            "upload_time_iso_8601": "2019-02-08T00:15:14.649897Z",
            "url": "https://files.pythonhosted.org/packages/c3/75/b5c7895b8d2edcecbc49b55adb10087183050f95eac33c3453cc12c610f1/jsoncomment-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-02-08 00:15:14",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "bitbucket_user": "Dando_Real_ITA",
    "bitbucket_project": "json-comment",
    "lcname": "jsoncomment"
}
        
Elapsed time: 0.40465s