1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-24 08:22:14 +02:00
A high-performance 100% compatible drop-in replacement of "encoding/json" http://jsoniter.com/migrate-from-go-std.html
Go to file
Tim Hockin 9215b3c508 Add output tests for builtin types
This fuzzes a type, marshals it with stdlib and json-iterator, compares,
then unmarshals with stdlib and json-iterator and compares.  This is
checking for literal, byte-for-byte compatibility.

In every case the test is exactly the same.

It also include benchmark functions to compare stdlib vs json-iterator.

This depends on a couple PRs to be merged in gofuzz.
2017-06-11 21:04:59 -07:00
.idea/libraries test more than one pakcage description 2017-06-11 15:32:58 +08:00
assert gofmt 2017-06-06 23:27:00 +08:00
output_tests/builtins Add output tests for builtin types 2017-06-11 21:04:59 -07:00
require fix 4 fields object decoding 2017-01-06 20:17:47 +08:00
example_test.go fix import not use 2017-06-09 16:28:20 +08:00
feature_adapter.go decoder/encoder;float precision doc 2017-06-11 16:28:31 +08:00
feature_any_array.go gofmt 2017-06-06 23:27:00 +08:00
feature_any_bool.go add all integer types 2017-01-29 16:55:32 +08:00
feature_any_float.go gofmt 2017-06-06 23:27:00 +08:00
feature_any_int32.go gofmt 2017-06-06 23:27:00 +08:00
feature_any_int64.go gofmt 2017-06-06 23:27:00 +08:00
feature_any_invalid.go add all integer types 2017-01-29 16:55:32 +08:00
feature_any_nil.go gofmt 2017-06-06 23:27:00 +08:00
feature_any_object.go gofmt 2017-06-06 23:27:00 +08:00
feature_any_string.go gofmt 2017-06-06 23:27:00 +08:00
feature_any_uint32.go add all integer types 2017-01-29 16:55:32 +08:00
feature_any_uint64.go gofmt 2017-06-06 23:27:00 +08:00
feature_any.go fix wrap any 2017-05-19 19:44:27 +08:00
feature_iter_array.go gofmt 2017-06-06 23:27:00 +08:00
feature_iter_float.go gofmt 2017-06-06 23:27:00 +08:00
feature_iter_int.go gofmt 2017-06-06 23:27:00 +08:00
feature_iter_object.go #50 map key unlike object field, can contain escaped char 2017-06-12 10:13:13 +08:00
feature_iter_skip.go gofmt 2017-06-06 23:27:00 +08:00
feature_iter_string.go report error when string end not found 2017-06-08 09:46:19 +08:00
feature_iter.go test more package description 2017-06-11 15:35:45 +08:00
feature_reflect_array.go gofmt 2017-06-06 23:27:00 +08:00
feature_reflect_map.go #50 map key unlike object field, can contain escaped char 2017-06-12 10:13:13 +08:00
feature_reflect_native.go #48 should return error if concrete tpye unknown 2017-06-09 17:06:27 +08:00
feature_reflect_object.go gofmt 2017-06-06 23:27:00 +08:00
feature_reflect.go decoder/encoder;float precision doc 2017-06-11 16:30:31 +08:00
feature_stream_float.go decoder/encoder;float precision doc 2017-06-11 16:28:31 +08:00
feature_stream_int.go gofmt 2017-06-06 23:27:00 +08:00
feature_stream.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_adapter_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_array_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_base64_test.go Formated, doced. Also fixed few minor bugs. 2017-01-05 21:23:08 +08:00
jsoniter_bool_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_customize_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_demo_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_find_end_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_float_test.go add test for scientific float 2017-06-07 21:34:56 +08:00
jsoniter_int_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_interface_test.go #48 should return error if concrete tpye unknown 2017-06-09 17:06:27 +08:00
jsoniter_io_test.go Formated, doced. Also fixed few minor bugs. 2017-01-05 21:23:08 +08:00
jsoniter_large_file_test.go Formated, doced. Also fixed few minor bugs. 2017-01-05 21:23:08 +08:00
jsoniter_map_test.go #50 map key unlike object field, can contain escaped char 2017-06-12 10:13:13 +08:00
jsoniter_nested_test.go Formated, doced. Also fixed few minor bugs. 2017-01-05 21:23:08 +08:00
jsoniter_null_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_object_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_optional_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_reflect_native_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_reflect_struct_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_reflect_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_skip_test.go Formated, doced. Also fixed few minor bugs. 2017-01-05 21:23:08 +08:00
jsoniter_stream_test.go gofmt 2017-06-06 23:27:00 +08:00
jsoniter_string_test.go #48 should return error if concrete tpye unknown 2017-06-09 17:06:27 +08:00
LICENSE Initial commit 2016-11-30 08:30:24 +08:00
README.md update benchmark 2017-06-06 16:55:32 +08:00

rcard

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

Benchmark

benchmark

Source code: https://github.com/json-iterator/go-benchmark/blob/master/src/github.com/json-iterator/go-benchmark/benchmark_medium_payload_test.go

Raw Result (easyjson requires static code generation)

ns/op allocation bytes allocation times
std decode 35510 ns/op 1960 B/op 99 allocs/op
easyjson decode 8499 ns/op 160 B/op 4 allocs/op
jsoniter decode 5623 ns/op 160 B/op 3 allocs/op
std encode 2213 ns/op 712 B/op 5 allocs/op
easyjson encode 883 ns/op 576 B/op 3 allocs/op
jsoniter encode 837 ns/op 384 B/op 4 allocs/op

Usage

100% compatibility with standard lib

Replace

import "encoding/json"
json.Marshal(&data)

with

import "github.com/json-iterator/go"
jsoniter.Marshal(&data)

Replace

import "encoding/json"
json.Unmarshal(input, &data)

with

import "github.com/json-iterator/go"
jsoniter.Unmarshal(input, &data)

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