dirtyjson is a Python JSON decoder (version 1.0.8, last updated Nov 2022) designed to extract data from malformed or 'dirty' JSON, often found embedded in JavaScript files. It tolerates common non-standard JSON elements like single quotes, comments (line and block), dangling commas, unquoted keys, and hexadecimal/octal numbers. It focuses solely on decoding and provides line/column number contexts for parsed elements. While its release cadence is infrequent, it remains active for specialized parsing needs.
pip install dirtyjsonVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a malformed JSON string with unquoted keys, single quotes, comments, and a dangling comma. It also shows how to access the positional attributes stored by dirtyjson and use the resulting AttributedDict as a standard dictionary.
Use `json.dumps()` or `json.dump()` for serialization.
Only use `dirtyjson` when strictly necessary for malformed input. Validate the output carefully if the input quality is highly variable or unpredictable.
Be aware of these non-standard interpretations and types when integrating with systems that expect strict JSON adherence or standard Python `dict`/`list` types without additional attributes.
Benchmark performance if critical, and consider strict JSON parsing for inputs that are expected to be well-formed.
No dependency data recorded yet.