A java library to repair broken JSON strings, particularly useful for handling malformed JSON output from Large Language Models.
This is a porting of the Python library json_repair, written by Stefano Baccianella and published under the MIT license.
All credits go to the original author for the amazing work.
We will try to keep up to tags of the original project, just push/fire an issue if delay.
<dependency>
<groupId>io.github.du00cs</groupId>
<artifactId>json-repairj</artifactId>
<version>${jsonRepairjVersion}</version>
</dependency>
implementation 'io.github.du00cs:json-repairj:${jsonRepairjVersion}'
import org.jsonrepair.JsonRepair;
String result = JsonRepair.repairJson(str);
// or more control (result = jackson node + warnings)
ParseResult result = JsonRepair.parseJson(str, skipLoads, streamStable);
Some features are not implemented yet:
- identity check in multiple json
- read from file
- stream stable not tested