| 1 | # sigs.k8s.io/json |
| 2 | |
| 3 | [](https://pkg.go.dev/sigs.k8s.io/json) |
| 4 | |
| 5 | ## Introduction |
| 6 | |
| 7 | This library is a subproject of [sig-api-machinery](https://github.com/kubernetes/community/tree/master/sig-api-machinery#json). |
| 8 | It provides case-sensitive, integer-preserving JSON unmarshaling functions based on `encoding/json` `Unmarshal()`. |
| 9 | |
| 10 | ## Compatibility |
| 11 | |
| 12 | The `UnmarshalCaseSensitivePreserveInts()` function behaves like `encoding/json#Unmarshal()` with the following differences: |
| 13 | |
| 14 | - JSON object keys are treated case-sensitively. |
| 15 | Object keys must exactly match json tag names (for tagged struct fields) |
| 16 | or struct field names (for untagged struct fields). |
| 17 | - JSON integers are unmarshaled into `interface{}` fields as an `int64` instead of a |
| 18 | `float64` when possible, falling back to `float64` on any parse or overflow error. |
| 19 | - Syntax errors do not return an `encoding/json` `*SyntaxError` error. |
| 20 | Instead, they return an error which can be passed to `SyntaxErrorOffset()` to obtain an offset. |
| 21 | |
| 22 | ## Additional capabilities |
| 23 | |
| 24 | The `UnmarshalStrict()` function decodes identically to `UnmarshalCaseSensitivePreserveInts()`, |
| 25 | and also returns non-fatal strict errors encountered while decoding: |
| 26 | |
| 27 | - Duplicate fields encountered |
| 28 | - Unknown fields encountered |
| 29 | |
| 30 | ### Community, discussion, contribution, and support |
| 31 | |
| 32 | You can reach the maintainers of this project via the |
| 33 | [sig-api-machinery mailing list / channels](https://github.com/kubernetes/community/tree/master/sig-api-machinery#contact). |
| 34 | |
| 35 | ### Code of conduct |
| 36 | |
| 37 | Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](code-of-conduct.md). |
| 38 | |
| 39 | [owners]: https://git.k8s.io/community/contributors/guide/owners.md |
| 40 | [Creative Commons 4.0]: https://git.k8s.io/website/LICENSE |