Documentation
¶
Index ¶
- func GetExtension(format string) string
- func JSONToYAML(jsonData []byte) ([]byte, error)
- func PrettyJSON(jsonData []byte) ([]byte, error)
- func PrettyYAML(yamlData []byte) ([]byte, error)
- func ValidateAndConvert(data []byte) ([]byte, error)
- func YAMLNodeFromJSON(v any) (any, error)
- func YAMLToJSON(yamlData []byte) ([]byte, error)
- type Format
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetExtension ¶
GetExtension returns the file extension for the format
func JSONToYAML ¶
JSONToYAML converts JSON data to YAML
func PrettyJSON ¶
PrettyJSON formats JSON with indentation
func PrettyYAML ¶
PrettyYAML formats YAML with proper indentation
func ValidateAndConvert ¶
ValidateAndConvert validates input data and converts it to JSON It auto-detects the format and converts YAML to JSON if needed
func YAMLNodeFromJSON ¶
YAMLNodeFromJSON renders a value through its JSON representation so that yaml.Marshal produces output structurally identical to json.Marshal.
It is the canonical implementation for a type's MarshalYAML when the type relies on JSON struct tags for its wire shape (json:"-" to hide display-only fields, omitempty, camelCase keys) and/or embeds []byte or json.RawMessage fields. Without it, yaml.v3 falls back to reflection: struct tags are ignored (keys are lowercased, omitempty is not honored, json:"-" fields leak in) and []byte/json.RawMessage fields are emitted as a sequence of raw byte values.
Numbers keep their JSON token: decoding them into float64 would round an integer above 2^53, and a document printed with `-o yaml` and applied back must carry the value the server sent.
json.Marshal never invokes MarshalYAML, so calling this from a MarshalYAML method does not recurse.
func YAMLToJSON ¶
YAMLToJSON converts YAML data to JSON