ghodss/yaml

Keys like "yes" and "on" are read as true

slntopp opened this issue · 4 comments

template = `
on:
 - RUNNING
`
template, _ = yaml.YAMLToJSON(template)
fmt.Println(string(template))
// => {"true":["DELETED"]}

I was about to open a similar issue. y is also read as true.
Not great but solved by quoting the property: "y"

yeah, I figured too, but unfortunately not a solution in my case :(

We have the same issue. It affects https://github.com/open-policy-agent/opa which uses this library.

I can see that would have been very annoying! It's to do with the way yaml.v2 was parsing keys as interface{} instead of string.. That still happens in yaml.v3, but only if all keys are non-strings. Moving to v3 should fix this.

Doesn't look there was much maintenance here, so I've forked this repo and upgraded to v3 if you'd like to test it: https://github.com/invopop/yaml