fixjson
fixjson
is a GoLang library designed to repair malformed JSON strings using the power of JavaScript's dynamic parsing capabilities. By leveraging the otto
JavaScript interpreter and jsonrepair
Javascript library, it attempts to parse and correct errors in JSON strings, making them valid and usable again.
Installation
To start using fixjson
, install Go and run go get
:
go get -u github.com/jaxmef/fixjson
Usage
Here's a simple example on how to use fixjson to repair a JSON string:
package main
import (
"fmt"
"github.com/jaxmef/fixjson"
)
func main() {
input := `{"name": "John Doe", "age": "30}` // Malformed JSON
fixedJSON, err := fixjson.FixJSON(input)
if err != nil {
fmt.Println("Error fixing JSON:", err)
return
}
fmt.Println("Repaired JSON:", fixedJSON)
}
Features
- Simple API: A straightforward and easy-to-use API to fix malformed JSON strings.
- JavaScript Powered: Utilizes the otto JavaScript engine to dynamically interpret and repair JSON strings.
- Flexible: Capable of handling a wide range of common JSON errors.
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
License
Released under the ISC license.
Acknowledgments
This library uses the otto JavaScript interpreter for Go: github.com/robertkrimen/otto
JSON repair functionality is provided by the jsonrepair JavaScript library: github.com/josdejong/jsonrepair