fixjson

package module
v0.0.0-...-b68e40d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2024 License: ISC Imports: 2 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixJSON

func FixJSON(input string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL