Support YAML to pretty JSON
davidxia opened this issue · 2 comments
davidxia commented
Thanks for this library!
Right now YAMLToJSON
prints the following YAML
t: a
as {"t":"a"}
.
Could you add support for printing the YAML as
{
"t": "a"
}
Basically add a way to use json.MarshalIndent
here.
davidxia commented
I tried making a PR, but I'm not that good at go :(
daftspunk commented
This might help
// Compile JSON
body, err := yaml.YAMLToJSON(yamlContents)
if err != nil {
panic(err)
}
// Beautify
var schemaObj map[string]interface{}
if err := json.Unmarshal(body, &schemaObj); err != nil {
panic(err)
}
body, err := json.MarshalIndent(schemaObj, "", " ")
if err != nil {
panic(err)
}