Skip to content
/ njson Public

High performance parsing and manipulation of JSON documents for Go

License

Notifications You must be signed in to change notification settings

alxarch/njson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5645168 · Dec 8, 2019
Nov 11, 2018
Nov 11, 2018
Sep 18, 2018
Nov 12, 2018
Oct 24, 2018
Sep 14, 2018
Dec 8, 2019
Nov 12, 2018
Nov 11, 2018
Oct 19, 2018
Nov 11, 2018
Aug 29, 2018
Nov 11, 2018
Nov 13, 2018
Nov 11, 2018
Nov 11, 2018
Nov 11, 2018
Dec 8, 2019
Oct 25, 2018
Nov 11, 2018
Dec 8, 2019
Dec 8, 2019
Nov 10, 2018
Nov 10, 2018
Nov 10, 2018
Nov 11, 2018
Nov 10, 2018
Oct 21, 2018

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

License

Stars

Watchers

Forks

Packages

No packages published

Languages