Go YAML marshaling that reuses JSON struct tags, by converting YAML to JSON (unmaintained)
open sourceMIT AND BSD-3-Clausefree
ghodss/yaml is a Go library that wraps go-yaml for a better way of marshaling YAML to and from structs: it converts YAML to JSON with go-yaml, then uses Go's encoding/json, so it reuses JSON struct tags and the custom MarshalJSON and UnmarshalJSON methods. It also converts between YAML and JSON directly. It hasn't changed since 2023; sigs.k8s.io/yaml is its permanent fork, maintained by Kubernetes.
Problems it solves
- use my existing JSON struct tags when reading YAML in Go
- convert YAML to JSON in a Go program
- unmarshal YAML into Go structs the same way as JSON
Features
- marshal and unmarshal YAML using JSON struct tags
- honours custom MarshalJSON and UnmarshalJSON methods
- convert YAML to JSON and JSON to YAML
Forks
- sigs.k8s.io/yaml Marshal Go structs to and from YAML using their JSON tags. Its own project.
Alternatives
The same job
These do what ghodss/yaml does.
- sigs.k8s.io/yaml Marshal Go structs to and from YAML using their JSON tags
- go-yaml (yaml/go-yaml) YAML for Go, maintained by the YAML organization
