from partialjson import JSONParser
parser = JSONParser()
incomplete_json = '{"name": "John Doe", "age": 30, "is_student": false, "courses": ["Math", "Science"'
print(parser.parse(incomplete_json))
# {'name': 'John Doe', 'age': 30, 'is_student': False, 'courses': ['Math', 'Science']}Problem with \n? Use strict=False:
from partialjson import JSONParser
parser = JSONParser(strict=False)
incomplete_json = '{"name": "John\nDoe", "age": 30, "is_student": false, "courses": ["Math", "Science"'
print(parser.parse(incomplete_json))
# {'name': 'John\nDoe', 'age': 30, 'is_student': False, 'courses': ['Math', 'Science']}Use create_json5_parser or JSONParser(json5_enabled=True) for JSON5 (comments, unquoted keys, single quotes, etc.):
from partialjson import create_json5_parser
parser = create_json5_parser()
incomplete_json5 = '{name: "Demo", version: 1.0, items: [1, 2, 3,]'
print(parser.parse(incomplete_json5))
# {'name': 'Demo', 'version': 1.0, 'items': [1, 2, 3]}Install the optional json5 dependency for full JSON5 support: pip install partialjson[json5]
$ pip install partialjsonAlso can be found on pypi
- Install the package by pip package manager.
- After installing, you can use it and call the library.
pip install -e .
pip install -r requirements-dev.txt
pytest -qIf you use this software, please cite it using the metadata in CITATION.cff.
Feel free to submit issues and enhancement requests or contact me via vida.page/nima.
Please refer to each project's style and contribution guidelines for submitting patches and additions. In general, we follow the "fork-and-pull" Git workflow.
- Fork the repo on GitHub
- Clone the project to your own machine
- Update the Version inside init.py
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes

