Home

Awesome

<!-- Improved compatibility of back to top link: See: https://github.com/RealAlexandreAI/json-repair/pull/73 -->

<a name="readme-top"></a>

<!-- *** Thanks for checking out the Best-README-Template. If you have a suggestion *** that would make this better, please fork the repo and create a pull request *** or simply open an issue with the tag "enhancement". *** Don't forget to give the project a star! *** Thanks again! Now go create something AMAZING! :D --> <!-- PROJECT SHIELDS --> <!-- *** I'm using markdown "reference style" links for readability. *** Reference links are enclosed in brackets [ ] instead of parentheses ( ). *** See the bottom of this document for the declaration of the reference variables *** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use. *** https://www.markdownguide.org/basic-syntax/#reference-style-links -->

Contributors Forks Stargazers Issues GPL License

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/RealAlexandreAI/json-repair"> <img src="images/logo.png" alt="Logo" width="80" height="80"> </a> <h3 align="center">json-repair</h3> <p align="center"> JSON Repair: Solution for JSON Anomalies from LLMs. <br /> <a href="https://goplay.tools/snippet/zyLfsLcsTwg">Online Playground</a> ยท <a href="https://github.com/RealAlexandreAI/json-repair/issues/new?labels=bug&template=bug-report---.md">Report Bug</a> ยท <a href="https://github.com/RealAlexandreAI/json-repair/issues/new?labels=enhancement&template=feature-request---.md">Request Feature</a> </p> </div> <!-- ABOUT THE PROJECT -->

๐Ÿ”ง Repair JSON! Solution for JSON Anomalies from LLMs

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.

๐ŸŽฏ Why Choose JSON Repair?

๐Ÿ” Supported Broken LLM JSON Output

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- GETTING STARTED -->

๐Ÿ Getting Started

To add the JSON Repair to your Go project, use the following command:

go get github.com/RealAlexandreAI/json-repair
<!-- USAGE EXAMPLES -->

Usage

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 <a href="https://goplay.tools/snippet/zyLfsLcsTwg">Online Playground</a>

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Terminal CLI


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.

<!-- ROADMAP -->

Roadmap

See the open issues for a full list of proposed features (and known issues).

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- CONTRIBUTING -->

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request
<p align="right">(<a href="#readme-top">back to top</a>)</p>

Related Project

<!-- LICENSE -->

License

Distributed under the GPLv3 License. See LICENSE for more information.

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- CONTACT -->

Contact

RealAlexandreAI - @RealAlexandreAI

Project Link: https://github.com/RealAlexandreAI/json-repair

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- MARKDOWN LINKS & IMAGES --> <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->