Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

148 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status GoDoc Go Report codecov

njson

High performance parsing and manipulation of JSON documents for Go.

Inspired by github.com/valyala/fastjson

Features

  • Does not try to be a 'drop-in' replacement for encoding/json
  • Deserialize arbitrary JSON input to a DOM tree
  • Manipulate DOM tree
  • Path lookups
  • Lazy unescape and number conversions for faster parsing
  • Reserialze to JSON data
  • Iterate over tree
  • Documents can be reused to avoid allocations
  • Fast, fast, fast
  • [WIP] Support for reflect based struct Marshal/Unmarshal via github.com/alxarch/njson/unjson package
  • [WIP] CLI tool for Marshal/Unmarshal generated code via github.com/alxarch/njson/cmd/njson package

Usage

	d := njson.Document{}

	root, _, _ := d.Parse(`{"answer":42, "foo": {"bar": "baz"}}`)

	answer, _ := root.Get("answer").ToInt()
	fmt.Println(answer)

	n := root.Lookup("foo", "bar")
	bar := n.Unescaped()
	fmt.Println(bar)

	n.SetString("Hello, 世界")

	data := make([]byte, 64)
	data, _ = root.AppendJSON(data[:0])
	fmt.Println(string(data))

	// Output:
	// 42
	// baz
	// {"answer":42,"foo":{"bar":"Hello, 世界"}}

About

High performance parsing and manipulation of JSON documents for Go

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages