[TOC] ## 概述 1. 快,并且更快 2. 支持 java 和 go 3. 100 兼容 json 标准库,一行代码迁移到 jsoniter |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 | ## 安装 `go get github.com/json-iterator/go` ## 使用 > 总之只需要在最前加上一行 `var json = jsoniter.ConfigCompatibleWithStandardLibrary` 即可 old ``` import "encoding/json" json.Marshal(&data) ``` new ``` import "github.com/json-iterator/go" var json = jsoniter.ConfigCompatibleWithStandardLibrary json.Marshal(&data) ``` --- old ``` import "encoding/json" json.Unmarshal(input, &data) ``` new ``` import "github.com/json-iterator/go" var json = jsoniter.ConfigCompatibleWithStandardLibrary json.Unmarshal(input, &data) ```