Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
slntopp opened this issue Apr 12, 2022 · 4 comments
Open

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

slntopp opened this issue Apr 12, 2022 · 4 comments

Comments

@slntopp
Copy link

slntopp commented Apr 12, 2022

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

s1moe2 commented Apr 21, 2022

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

@slntopp
Copy link
Author

slntopp commented Apr 22, 2022

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

@fproulx-boostsecurity
Copy link

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

@samlown
Copy link

samlown commented May 27, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants