mirror of
https://github.com/kubernetes/sample-controller.git
synced 2025-01-21 09:22:50 +08:00
46b5d73382
Automatic merge from submit-queue (batch tested with PRs 57122, 57142, 57016, 56927, 56678). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. bump(13f864): github.com/json-iterator/go: use ConfigCompatibleWithStandardLibrary Jsoniter in `ConfigFastest` mode does not support escape characters in object keys, whereas `ConfigCompatibleWithStandardLibrary` does. Fixes kubernetes/kubernetes#56018 Related kubernetes/kubernetes#56055 Benchmark results: ``` BenchmarkDecodeIntoJSON-4 30000 48522 ns/op 3792 B/op 63 allocs/op BenchmarkDecodeIntoJSONCodecGenConfigFast-4 100000 17409 ns/op 4524 B/op 96 allocs/op BenchmarkDecodeIntoJSONCodecGenConfigCompatibleWithStandardLibrary-4 100000 18617 ns/op 4924 B/op 121 allocs/op ``` /assign sttts thockin mfojtik Kubernetes-commit: 135d58b3941fac99ae0426e18cbda266b83ca49e
2.7 KiB
2.7 KiB
A high-performance 100% compatible drop-in replacement of "encoding/json"
Go开发者们请加入我们,滴滴出行平台技术部 taowen@didichuxing.com
Benchmark
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"
var json = jsoniter.ConfigCompatibleWithStandardLibrary
json.Marshal(&data)
Replace
import "encoding/json"
json.Unmarshal(input, &data)
with
import "github.com/json-iterator/go"
var json = jsoniter.ConfigCompatibleWithStandardLibrary
json.Unmarshal(input, &data)
How to get
go get github.com/json-iterator/go
Contribution Welcomed !
Contributors
Report issue or pull request, or email taowen@gmail.com, or