Skip to main content

JSON with Comments (jsonc) for Python

Project description

JSON with Comments for Python

pypi version Python package Python Versions

Features

  • load(), loads()
    • Remove single line (//) and block comments (/* */)
    • Remove trailing commas from arrays and objects
  • dump(), dumps()
    • Add comments
    • Add trailing commas

Usage

pip install json-with-comments
>>> import jsonc
>>> jsonc.loads("{// comment \n}")
{}
>>> jsonc.loads("{/* comment */}")
{}
>>> jsonc.loads('{"spam": "ham // egg" /* comment */}')
{'spam': 'ham // egg'}
>>> jsonc.loads('{"spam": /* comment */"ham /* egg */"}')
{'spam': 'ham /* egg */'}

And just like json module

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_with_comments-1.2.9.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

json_with_comments-1.2.9-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

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