Documentation ¶
Overview ¶
Package codectool provides some codec tools for JSON and YAML marshaling.
Index ¶
- func Decode(r io.Reader, v interface{}) error
- func DecodeJSON(r io.Reader, v interface{}) error
- func DecodeYAML(r io.Reader, v interface{}) error
- func EncodeJSON(w io.Writer, v interface{}) error
- func EncodeYAML(w io.Writer, v interface{}) error
- func JSONToYAML(in []byte) ([]byte, error)
- func MarshalJSON(v interface{}) ([]byte, error)
- func MarshalYAML(v interface{}) ([]byte, error)
- func MustDecode(r io.Reader, v interface{})
- func MustDecodeJSON(r io.Reader, v interface{})
- func MustDecodeYAML(r io.Reader, v interface{})
- func MustEncodeJSON(w io.Writer, v interface{})
- func MustEncodeYAML(w io.Writer, v interface{})
- func MustJSONToYAML(in []byte) []byte
- func MustMarshalJSON(v interface{}) []byte
- func MustMarshalYAML(v interface{}) []byte
- func MustUnmarshal(data []byte, v interface{})
- func MustUnmarshalJSON(data []byte, v interface{})
- func MustUnmarshalYAML(data []byte, v interface{})
- func MustYAMLToJSON(in []byte) []byte
- func StructToMap(s interface{}) (map[string]interface{}, error)
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalJSON(data []byte, v interface{}) error
- func UnmarshalYAML(data []byte, v interface{}) error
- func YAMLToJSON(in []byte) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode decodes a json stream into a value of the given type. It converts yaml to json before decoding by leveraging Unmarshal.
func DecodeJSON ¶
DecodeJSON decodes a json stream into a value of the given type.
func DecodeYAML ¶
DecodeYAML decodes a yaml stream into a value of the given type.
func EncodeJSON ¶
EncodeJSON encodes a value into a json stream.
func EncodeYAML ¶
EncodeYAML encodes a value into a yaml stream.
func JSONToYAML ¶
JSONToYAML converts a json stream into a yaml stream.
func MarshalYAML ¶
MarshalYAML wraps yaml.MarshalYAML.
func MustDecode ¶
MustDecode decodes a json stream into a value of the given type. It converts yaml to json before decoding by leveraging Unmarshal. It panics if an error occurs.
func MustDecodeJSON ¶
MustDecodeJSON decodes a json stream into a value of the given type. It panics if an error occurs.
func MustDecodeYAML ¶
MustDecodeYAML decodes a yaml stream into a value of the given type. It panics if an error occurs.
func MustEncodeJSON ¶
MustEncodeJSON encodes a value into a json stream. It panics if an error occurs.
func MustEncodeYAML ¶
MustEncodeYAML encodes a value into a yaml stream. It panics if an error occurs.
func MustJSONToYAML ¶
MustJSONToYAML converts a json stream into a yaml stream. It panics if an error occurs.
func MustMarshalJSON ¶
func MustMarshalJSON(v interface{}) []byte
MustMarshalJSON wraps json.Marshal by panic instead of returning error.
func MustMarshalYAML ¶
func MustMarshalYAML(v interface{}) []byte
MustMarshalYAML wraps yaml.Marshal by panic instead of returning error.
func MustUnmarshal ¶
func MustUnmarshal(data []byte, v interface{})
MustUnmarshal wraps json.MustUnmarshal by panic instead of returning error. It converts yaml to json before decoding by leveraging Unmarshal. It panics if an error occurs.
func MustUnmarshalJSON ¶
func MustUnmarshalJSON(data []byte, v interface{})
MustUnmarshalJSON wraps json.Unmarshal. It panics if an error occurs.
func MustUnmarshalYAML ¶
func MustUnmarshalYAML(data []byte, v interface{})
MustUnmarshalYAML wraps yaml.Unmarshal by panic instead of returning error.
func MustYAMLToJSON ¶
MustYAMLToJSON converts a json stream into a yaml stream. It panics if an error occurs.
func StructToMap ¶
StructToMap converts a struct to a map based on json marshal.
func Unmarshal ¶
Unmarshal wraps json.Unmarshal. It will convert yaml to json before unmarshal. Since json is a subset of yaml, passing json through this method should be a no-op.
func UnmarshalJSON ¶
UnmarshalJSON wraps json.Unmarshal.
func UnmarshalYAML ¶
UnmarshalYAML wraps yaml.Unmarshal.
func YAMLToJSON ¶
YAMLToJSON converts a yaml stream into a json stream.
Types ¶
This section is empty.