github.com/cosmos/cosmos-sdk@v0.50.10/codec/yaml.go (about) 1 package codec 2 3 import ( 4 "github.com/cosmos/gogoproto/proto" 5 "sigs.k8s.io/yaml" 6 ) 7 8 // MarshalYAML marshals toPrint using JSONCodec to leverage specialized MarshalJSON methods 9 // (usually related to serialize data with protobuf or amin depending on a configuration). 10 // This involves additional roundtrip through JSON. 11 func MarshalYAML(cdc JSONCodec, toPrint proto.Message) ([]byte, error) { 12 // We are OK with the performance hit of the additional JSON roundtip. MarshalYAML is not 13 // used in any critical parts of the system. 14 bz, err := cdc.MarshalJSON(toPrint) 15 if err != nil { 16 return nil, err 17 } 18 19 return yaml.JSONToYAML(bz) 20 }