How mangiucugna/json_repair works
Project type and purpose
• This is a standalone, open-source Python library and CLI tool (“json_repair”) whose sole purpose is to take malformed JSON strings or streams, repair them using simple heuristics, and return either a valid JSON string or a native Python object.
File structure
• Top-level folders:
• src/json_repair: the core package
• docs: static demo site sources (HTML/JS/CSS)
• tests: unit tests and performance tests
• Key modules under src/json_repair:
• __main__.py – CLI entry point
• json_repair.py – public API (repair_json, loads, load, from_file)
• json_parser.py – low-level BNF-based parser and scanner
• json_context.py – parse state and token management
• object_comparer.py – logic to compare/merge default values
• string_file_wrapper.py – adapter for file/stream inputs
• Configuration/build:
• pyproject.toml + requirements.txt for packaging
• GitHub Actions workflows for test & publish
• pre-commit for linting/testing
README for additional insights
• No external runtime dependencies beyond the Python standard library (uses json.loads under the hood unless skipped)
• Demonstrates both library usage (API) and CLI usage
• Mentions performance-tuning flags (skip_json_loads, stream_stable) and non-Latin handling (ensure_ascii)