jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
Go
Permalink
Failed to load latest commit information.
assert fix 4 fields object decoding Jan 6, 2017
require fix 4 fields object decoding Jan 6, 2017
LICENSE Initial commit Nov 30, 2016
README.md Formated, doced. Also fixed few minor bugs. Jan 5, 2017
any_test.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
feature_adapter.go struct encoder Jan 9, 2017
feature_any.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
feature_iter_float.go fix read int ranges Jan 15, 2017
feature_iter_int.go fix int min max Jan 16, 2017
feature_iter_object.go test read string and read string as slice Jan 16, 2017
feature_iter_string.go test read string and read string as slice Jan 16, 2017
feature_reflect.go test array of interface Jan 9, 2017
feature_reflect_array.go array encoder Jan 9, 2017
feature_reflect_native.go test array of interface Jan 9, 2017
feature_reflect_object.go array encoder Jan 9, 2017
feature_stream_float.go write float64 Jan 7, 2017
feature_stream_int.go write object Jan 7, 2017
iterator.go test read string and read string as slice Jan 16, 2017
jsoniter_any_test.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
jsoniter_array_test.go array encoder Jan 9, 2017
jsoniter_base64_test.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
jsoniter_bool_test.go struct encoder Jan 9, 2017
jsoniter_customize_test.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
jsoniter_demo_test.go support int/string encode Jan 9, 2017
jsoniter_find_end_test.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
jsoniter_float_test.go optimize read float64 Jan 15, 2017
jsoniter_int_test.go fix int min max Jan 16, 2017
jsoniter_interface_test.go test array of interface Jan 9, 2017
jsoniter_io_test.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
jsoniter_large_file_test.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
jsoniter_map_test.go encode optional Jan 9, 2017
jsoniter_nested_test.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
jsoniter_null_test.go add stream Jan 7, 2017
jsoniter_object_test.go write object Jan 7, 2017
jsoniter_optional_test.go encode optional Jan 9, 2017
jsoniter_reflect_native_test.go support int/string encode Jan 9, 2017
jsoniter_reflect_struct_test.go encode optional Jan 9, 2017
jsoniter_reflect_test.go implement readFloat32 fast path Jan 15, 2017
jsoniter_skip_test.go Formated, doced. Also fixed few minor bugs. Jan 5, 2017
jsoniter_string_test.go test read string and read string as slice Jan 16, 2017
stream.go array encoder Jan 9, 2017

README.md

rcard

jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go

Why jsoniter?

  • Jsoniter is the fastest JSON parser. It could be up to 10x faster than normal parser, data binding included. Shameless self benchmark
  • Extremely flexible api. You can mix and match three different styles: bind-api, any-api or iterator-api. Checkout your api choices
  • Unique iterator api can iterate through JSON directly, zero memory allocation! See how iterator works

Show off

Here is a quick show off, for more complete report you can checkout the full benchmark with in-depth optimization to back the numbers up

go-medium

Bind-API is the best

Bind-api should always be the first choice. Given this JSON document [0,1,2,3]

Parse with Go bind-api

import "github.com/json-iterator/go"
iter := jsoniter.ParseString(`[0,1,2,3]`)
val := []int{}
iter.Read(&val)
fmt.Println(val[3])

Iterator-API for quick extraction

When you do not need to get all the data back, just extract some.

Parse with Go iterator-api

import "github.com/json-iterator/go"
iter := ParseString(`[0, [1, 2], [3, 4], 5]`)
count := 0
for iter.ReadArray() {
    iter.Skip()
    count++
}
fmt.Println(count) // 4

Any-API for maximum flexibility

Parse with Go any-api

import "github.com/json-iterator/go"
iter := jsoniter.ParseString(`[{"field1":"11","field2":"12"},{"field1":"21","field2":"22"}]`)
val := iter.ReadAny()
fmt.Println(val.ToInt(1, "field2")) // 22

Notice you can extract from nested data structure, and convert any type to the type to you want.

How to get

go get github.com/json-iterator/go

Contribution Welcomed !

Report issue or pull request, or email taowen@gmail.com, or Gitter chat