JSON Repair: Solution for JSON Anomalies from LLMs.
Online Playground
·
Report Bug
·
Request Feature
Welcome to the json-repair, your go-to solution for fixing those pesky JSON anomalies that can sidetrack your Large Language Model (LLM) processes. Our toolkit is designed to be the Swiss Army knife for all your JSON repair needs.
"
n
{"key": TRUE, "key2": FALSE, "key3": Null
{'key': 'string', 'key2': false, "key3": null, "key4": unquoted}
[1, 2, 3, 4
{"employees":["John", "Anna",
[
]
[[1nn]
{foo: [}
{"text": "The quick brown fox won't jump"}
{"value_1": "value_2": "data"}
{"value_1": true, COMMENT "value_2": "data"}
- { "test_key": ["test_value", "test_value2"] }
{ "content": "[LINK]("https://google.com")" }
{ "content": "[LINK](" }
{ "content": "[LINK](", "key": true }
{"key":"",}
(back to top)
To add the JSON Repair to your Go project, use the following command:
go get github.com/RealAlexandreAI/json-repair
package main
import (
"github.com/RealAlexandreAI/json-repair"
)
func main() {
// broken JSON string from LLM
in := "```json {'employees':['John', 'Anna', ```"
jsonrepair.RepairJSON(in)
// output: {"employees":["John","Anna"]}
}
Additionally, there is
MustRepairJSON
for scenarios that are not suitable for error handling, such as pipes and trusted environments
For more examples, please refer to the Test Cases Or Online Playground
(back to top)
brew install realalexandreai/tap-jsonrepair/jsonrepair
# from raw string
jsonrepair -i "{'employees':['John', 'Anna', "
# output: {"employees":["John", "Anna", "Peter"]}
# from file
jsonrepair -f <json-file>.json
You can also download binary from Release, please refer to the Releases.
See the open issues for a full list of proposed features (and known issues).
(back to top)
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)(back to top)
Distributed under the GPLv3 License. See LICENSE
for more information.
(back to top)
RealAlexandreAI - @RealAlexandreAI
Project Link: https://github.com/RealAlexandreAI/json-repair
(back to top)