Documentation ¶
Overview ¶
Package json provides json specific functionality like rfc 6902 patching and convertion between json and yaml formatted maps.
Index ¶
- Variables
- func ConvertMapIToMapS(mapI interface{}) interface{}
- func ConvertMapSToMapI(mapS interface{}) interface{}
- func MarshalYaml(in interface{}) ([]byte, error)
- func Patch(data interface{}, patchBytes ...[]byte) (interface{}, error)
- func PatchFromFiles(data interface{}, patchFiles ...string) (interface{}, error)
- func PatchFromStrings(data interface{}, patchStrings ...string) (interface{}, error)
- func UnmarshalAllYaml(yamlString string) ([]interface{}, error)
- func UnmarshalSingleYaml(yamlString string) (interface{}, error)
- func UnmarshalYamlInterface(yamlStrings ...string) (interface{}, error)
- func YAMLToJSON(data []byte) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
var ( JSONObjectPrefix = []byte("{") JSONArrayPrefix = []byte("[") )
Functions ¶
func ConvertMapIToMapS ¶
func ConvertMapIToMapS(mapI interface{}) interface{}
ConvertMapIToMapS will convert a map of the format created by yaml.Unmarshal to the format created by json.Unmarshal. Specifically, json uses string keys, while yaml uses interface{} keys.
https://stackoverflow.com/a/40737676/516433
func ConvertMapSToMapI ¶
func ConvertMapSToMapI(mapS interface{}) interface{}
ConvertMapSToMapI will convert a map of the format created by json.Unmarshal to the format created by yaml.Unmarshal. Specifically, json uses string keys, while yaml uses interface{} keys.
https://stackoverflow.com/a/40737676/516433
func MarshalYaml ¶
MarshalYaml will convert an object to yaml
func PatchFromFiles ¶
PatchFromFiles applies a list of rfc 6902 patches to the data.
func PatchFromStrings ¶
PatchFromStrings applies a list of rfc 6902 patches to the data.
func UnmarshalAllYaml ¶
UnmarshalAllYaml will unmarshal all yaml docs in a single yaml/json string without merging. This form works for any yaml data, not just objects.
func UnmarshalSingleYaml ¶
UnmarshalSingleYaml will unmarshal the first yaml doc in a single yaml/json string without merging. This form works for any yaml data, not just objects.
func UnmarshalYamlInterface ¶
UnmarshalYamlInterface will parse all the supplied yaml strings, merge the resulting objects, and return the resulting map. If a root node is a list it will be converted to an int map prior to merging. An emtpy document returns nil.
func YAMLToJSON ¶
YAMLToJSON converts yaml bytes to json bytes. This is useful for other packages that have json specific unmarshaling code (ie: json-patch). The approach is inspired by:
https://github.com/kubernetes-sigs/yaml/blob/9535b3b1e2893fe44efb37c5c9f5665e245d786a/yaml.go
Types ¶
This section is empty.