Documentation
¶
Overview ¶
Package json is forked from the Go standard library to enable us to find the field of a struct that a given JSON key maps to.
Index ¶
- func ConvertInterfaceNumbers(v *interface{}, depth int) error
- func ConvertMapNumbers(m map[string]interface{}, depth int) error
- func ConvertSliceNumbers(s []interface{}, depth int) error
- func LookupPatchMetadataForStruct(t reflect.Type, jsonField string) (elemType reflect.Type, patchStrategies []string, patchMergeKey string, e error)
- func Marshal(v interface{}) ([]byte, error)
- func Unmarshal(data []byte, v interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertInterfaceNumbers ¶
ConvertInterfaceNumbers converts any json.Number values to int64 or float64. Values which are map[string]interface{} or []interface{} are recursively visited
func ConvertMapNumbers ¶
ConvertMapNumbers traverses the map, converting any json.Number values to int64 or float64. values which are map[string]interface{} or []interface{} are recursively visited
func ConvertSliceNumbers ¶
ConvertSliceNumbers traverses the slice, converting any json.Number values to int64 or float64. values which are map[string]interface{} or []interface{} are recursively visited
func LookupPatchMetadataForStruct ¶
func LookupPatchMetadataForStruct(t reflect.Type, jsonField string) ( elemType reflect.Type, patchStrategies []string, patchMergeKey string, e error)
Finds the patchStrategy and patchMergeKey struct tag fields on a given struct field given the struct type and the JSON name of the field. It returns field type, a slice of patch strategies, merge key and error. TODO: fix the returned errors to be introspectable.
func Marshal ¶
Marshal delegates to json.Marshal It is only here so this package can be a drop-in for common encoding/json uses
func Unmarshal ¶
Unmarshal unmarshals the given data. Object keys are case-sensitive. Numbers decoded into interface{} fields are converted to int64 or float64.
Upstream delegates to sigs.k8s.io/json's case-sensitive, int-preserving decoder. Here encoding/json decodes with UseNumber and the conversion below turns each json.Number into int64 or float64 the same way. encoding/json matches struct fields case-insensitively, so only the untyped targets the patch code decodes into are accepted; any other target is an error rather than a silently different decode.
Types ¶
This section is empty.