General Introduction
A module for fixing invalid JSON files, especially for parsing incorrect JSON data output by Large Language Models (LLMs). The module fixes common JSON syntax errors such as missing quotes, incorrect commas, unescaped characters and incomplete key-value pairs. It also auto-completes missing JSON values to ensure data validity.
Key Features.
Fix JSON syntax errors, such as missing quotes, misplaced commas, unescaped characters, etc.
Fixing incorrectly formatted JSON arrays and objects
Auto-completion of missing JSON values
Provides alternatives to json.loads() and json.load().
Language versions
Python version: https://github.com/mangiucugna/json_repair
Typescript version: https://github.com/josdejong/jsonrepair
Go version: https://github.com/RealAlexandreAI/json-repair
Ruby version: https://github.com/sashazykov/json-repair-rb
clarification
- Fix JSON syntax errors::
- Missing quotes: Automatically adds missing quotes to ensure that both keys and values are properly referenced.
- Incorrect commas: Fixes redundant or missing commas and ensures the integrity of the JSON structure.
- Unescaped characters: automatically escapes special characters to ensure the validity of JSON strings.
- Incomplete key-value pairs: Completes missing keys or values to ensure the integrity of each key-value pair.
- Fixing JSON arrays and objects::
- Incomplete arrays/objects: fix by adding necessary elements (e.g., commas, brackets) or default values (e.g., null, empty string).
- Handling of data containing additional non-JSON characters: clean up comments or incorrectly placed characters to maintain a valid structure.
- Auto-completion of missing JSON values::
- Automatically populate JSON fields with sensible default values (e.g. empty string or null) to ensure data validity.
- Cleaning up non-JSON characters::
- Handles data containing additional non-JSON characters, such as comments or incorrectly placed characters, maintaining a valid structure.