github.com/bingoohuang/gg@v0.0.0-20240325092523-45da7dee9335/pkg/jsoni/README.md (about) 1 # jsoni 2 3 A high-performance 100% compatible drop-in replacement of "encoding/json" 4 5 1. keep synchronized with [json-iterator](https://github.com/json-iterator/go) at commit `024077e@2021-09-11T10:17:26+08:00` 6 7 ## Features enhanced 8 9 1. Support converting between int64/uint64 and string values ( used for Javascript lost accuracy for int64/uint64) . eg. `c := jsoni.Config{EscapeHTML: true, Int64AsString: true}.Froze()` 10 2. Naming strategies for struct can be set on config. eg. `c.RegisterExtension(&extra.NamingStrategyExtension{Translate: strcase.ToCamelLower})` 11 3. Config.OmitEmptyMapKeys to omit keys whose value is empty. 12 13 You can also use thrift like JSON using [thrift-iterator](https://github.com/thrift-iterator/go) 14 15 ## Benchmark 16 17  18 19 Source code: https://github.com/json-iterator/go-benchmark/blob/master/src/github.com/json-iterator/go-benchmark/benchmark_medium_payload_test.go 20 21 Raw Result (easyjson requires static code generation) 22 23 | | ns/op | allocation bytes | allocation times | 24 | --------------- | ----------- | ---------------- | ---------------- | 25 | std decode | 35510 ns/op | 1960 B/op | 99 allocs/op | 26 | easyjson decode | 8499 ns/op | 160 B/op | 4 allocs/op | 27 | jsoniter decode | 5623 ns/op | 160 B/op | 3 allocs/op | 28 | std encode | 2213 ns/op | 712 B/op | 5 allocs/op | 29 | easyjson encode | 883 ns/op | 576 B/op | 3 allocs/op | 30 | jsoniter encode | 837 ns/op | 384 B/op | 4 allocs/op | 31 32 Always benchmark with your own workload. 33 The result depends heavily on the data input. 34 35 # Usage 36 37 100% compatibility with standard lib 38 39 Replace 40 41 ```go 42 import "encoding/json" 43 json.Marshal(&data) 44 ``` 45 46 with 47 48 ```go 49 import jsoniter "github.com/json-iterator/go" 50 51 var json = jsoniter.ConfigCompatibleWithStandardLibrary 52 json.Marshal(&data) 53 ``` 54 55 Replace 56 57 ```go 58 import "encoding/json" 59 json.Unmarshal(input, &data) 60 ``` 61 62 with 63 64 ```go 65 import jsoniter "github.com/json-iterator/go" 66 67 var json = jsoniter.ConfigCompatibleWithStandardLibrary 68 json.Unmarshal(input, &data) 69 ``` 70 71 [More documentation](http://jsoniter.com/migrate-from-go-std.html) 72 73 # How to get 74 75 ``` 76 go get github.com/json-iterator/go 77 ``` 78 79 # Contribution Welcomed ! 80 81 Contributors 82 83 - [thockin](https://github.com/thockin) 84 - [mattn](https://github.com/mattn) 85 - [cch123](https://github.com/cch123) 86 - [Oleg Shaldybin](https://github.com/olegshaldybin) 87 - [Jason Toffaletti](https://github.com/toffaletti) 88 89 Report issue or pull request, or email taowen@gmail.com, or [](https://gitter.im/json-iterator/Lobby)