Documentation ¶
Overview ¶
Package encoding provides encoding utilities.
Index ¶
- func GetJSONStringOrStringValue(rawMessage json.RawMessage) string
- func InterfaceSliceOrStringToCommaSepString(in interface{}) (string, error)
- func MarshalYAML(v interface{}) (_ []byte, retErr error)
- func NewYAMLDecoderNonStrict(reader io.Reader) *yaml.Decoder
- func NewYAMLDecoderStrict(reader io.Reader) *yaml.Decoder
- func NewYAMLEncoder(writer io.Writer) *yaml.Encoder
- func UnmarshalJSONNonStrict(data []byte, v interface{}) error
- func UnmarshalJSONOrYAMLNonStrict(data []byte, v interface{}) error
- func UnmarshalJSONOrYAMLStrict(data []byte, v interface{}) error
- func UnmarshalJSONStrict(data []byte, v interface{}) error
- func UnmarshalYAMLNonStrict(data []byte, v interface{}) error
- func UnmarshalYAMLStrict(data []byte, v interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetJSONStringOrStringValue ¶
func GetJSONStringOrStringValue(rawMessage json.RawMessage) string
GetJSONStringOrStringValue returns the JSON string for the RawMessage if the RawMessage is a string, and the raw value as a string otherwise.
If the RawMessage is empty, this returns "".
func InterfaceSliceOrStringToCommaSepString ¶
InterfaceSliceOrStringToCommaSepString parses the input as a slice or string into a comma separated string. This is commonly used with JSON or YAML fields that need to support both string slices and string literals.
func MarshalYAML ¶
MarshalYAML marshals the given value into YAML.
func NewYAMLDecoderNonStrict ¶
NewYAMLDecoderNonStrict creates a new YAML decoder from the reader.
func NewYAMLDecoderStrict ¶
NewYAMLDecoderStrict creates a new YAML decoder from the reader.
func NewYAMLEncoder ¶
NewYAMLEncoder creates a new YAML encoder reader from the Writer. The encoder must be closed after use.
func UnmarshalJSONNonStrict ¶
UnmarshalJSONNonStrict unmarshals the data as JSON, returning a user error on failure.
If the data length is 0, this is a no-op.
func UnmarshalJSONOrYAMLNonStrict ¶
UnmarshalJSONOrYAMLNonStrict unmarshals the data as JSON or YAML in order, returning a user error with both errors on failure.
If the data length is 0, this is a no-op.
func UnmarshalJSONOrYAMLStrict ¶
UnmarshalJSONOrYAMLStrict unmarshals the data as JSON or YAML in order, returning a user error with both errors on failure.
If the data length is 0, this is a no-op.
func UnmarshalJSONStrict ¶
UnmarshalJSONStrict unmarshals the data as JSON, returning a user error on failure.
If the data length is 0, this is a no-op.
func UnmarshalYAMLNonStrict ¶
UnmarshalYAMLNonStrict unmarshals the data as YAML, returning a user error on failure.
If the data length is 0, this is a no-op.
func UnmarshalYAMLStrict ¶
UnmarshalYAMLStrict unmarshals the data as YAML, returning a user error on failure.
If the data length is 0, this is a no-op.
Types ¶
This section is empty.