1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-30 08:36:43 +02:00
json-iterator/README.md

63 lines
1.5 KiB
Markdown
Raw Normal View History

[![rcard](https://goreportcard.com/badge/github.com/json-iterator/go)](https://goreportcard.com/report/github.com/json-iterator/go)
2016-12-11 17:55:55 +02:00
jsoniter (json-iterator) is fast and flexible JSON parser available in [Java](https://github.com/json-iterator/java) and [Go](https://github.com/json-iterator/go)
2016-11-30 18:56:25 +02:00
2017-06-06 10:54:26 +02:00
# Benchmark
![benchmark](http://jsoniter.com/benchmarks/go-benchmark.png)
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 |
2017-06-06 10:55:32 +02:00
| --- | --- | --- | --- |
2017-06-06 10:54:26 +02:00
| 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 |
2017-06-02 05:20:24 +02:00
# Usage
2016-11-30 18:56:25 +02:00
2017-06-02 05:20:24 +02:00
100% compatibility with standard lib
2016-12-12 19:13:15 +02:00
2017-06-02 05:20:24 +02:00
Replace
2016-12-12 19:13:15 +02:00
2017-06-02 05:20:54 +02:00
```go
2017-06-02 05:20:24 +02:00
import "encoding/json"
json.Marshal(&data)
```
2016-12-12 02:08:37 +02:00
2017-06-02 05:20:24 +02:00
with
2016-12-12 02:08:37 +02:00
2017-06-02 05:20:54 +02:00
```go
2016-12-12 02:08:37 +02:00
import "github.com/json-iterator/go"
2017-06-02 05:20:24 +02:00
jsoniter.Marshal(&data)
2016-12-12 02:08:37 +02:00
```
2017-06-02 05:20:24 +02:00
Replace
2016-12-12 02:08:37 +02:00
2017-06-02 05:20:54 +02:00
```go
2017-06-02 05:20:24 +02:00
import "encoding/json"
json.Unmarshal(input, &data)
2016-12-12 02:08:37 +02:00
```
2017-06-02 05:20:24 +02:00
with
2016-12-15 17:49:56 +02:00
2017-06-02 05:20:54 +02:00
```go
2016-12-15 17:49:56 +02:00
import "github.com/json-iterator/go"
2017-06-02 05:20:24 +02:00
jsoniter.Unmarshal(input, &data)
2016-12-15 17:49:56 +02:00
```
2016-12-12 02:08:37 +02:00
# 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](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/json-iterator/Lobby)