Registry / devops / json-with-comments

json-with-comments

JSON →
library1.2.10pypypi✓ verified 84d ago

A Python library that extends standard JSON parsing to support comments (both // line and /* block */), trailing commas, single quotes, and unquoted keys, conforming to the jsonc spec. Current version 1.2.10, release cadence: irregular.

pip install json-with-comments
INSTALL
IMPORT
SIG · JSON-WITH-COMMENTS
J
json-with-comments
devopspythonv1.2.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

loads
from jsonc import loads
import json_with_comments; json_with_comments.loads()
The package is installed as 'json-with-comments' but the module name is 'jsonc'. The top-level function is load/loads.
load
from jsonc import load
from jsonc.parser import parse
Internal module structure may change; use top-level imports.

Parse a JSON with comments string into a Python dict.

from jsonc import loads jsonc_str = '''{ // This is a comment "name": "Python", "version": 1.2.10 /* block comment */ }''' data = loads(jsonc_str) print(data)
Debug
Known issues
gotchaThe module name is 'jsonc', not 'json_with_comments'. Pip installs the package as 'json-with-comments' but you must import 'jsonc'.
fix
Use 'from jsonc import loads' not 'from json_with_comments import loads'.
affects: all
gotchaThe library does not preserve comments when dumping JSON back to string; dumps() produces standard JSON without comments.
fix
If you need to preserve comments, consider jsonc-parser or strip-comments manually.
affects: all
breakingVersion 1.0.0 changed the top-level API: 'from jsonc import loads' replaced the earlier 'json_with_comments.loads' pattern.
fix
Update imports to 'from jsonc import loads'.
affects: <1.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'json_with_comments'
Incorrect import path. The package installs as 'json-with-comments' but the module is 'jsonc'.
fix
Use 'from jsonc import loads' instead.
AttributeError: module 'jsonc' has no attribute 'loads'
You may have accidentally shadowed the module with a local file named jsonc.py or the installed version is too old (<1.0.0).
fix
Check for naming conflicts in the current directory, and upgrade to latest version: pip install --upgrade json-with-comments.
Upgrade
Version history
1.2.10latest on PyPI · released Dec 10, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
json-with-comments — pip install json-with-comments · libregistry