Skip to content

leowilbur/gojson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gojson

Gojson is a lightweight and fast JSON parser for Go. It is inspired by gjson, but adds a new Set method to make it easier to modify existing JSON documents.

Installation

To install gojson, use go get:

go get github.com/leowilbur/gojson

Usage

Gojson provides a simple API for parsing and manipulating JSON documents.

Parsing

To parse a JSON document, use the Parse function:

data := `{"name": "John Doe", "age": 42}`

json, err := gojson.Parse(data)
if err != nil {
    // handle error
}

Accessing Values

Once you have parsed a JSON document, you can access its values using the Get method:

name := json.Get("name").String() // "John Doe"
age := json.Get("age").Int() // 42

Modifying Values

Gojson also provides a Set method for modifying existing values in a JSON document:

gojson.Set("name", "Jane Doe")
gojson.Set("age", 43)

Serializing

To serialize a JSON document, use the String method:

data := json.String() // {"name": "Jane Doe", "age": 43}

License

Gojson is released under the MIT license. See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages