-
Notifications
You must be signed in to change notification settings - Fork 228
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
Comments
I was about to open a similar issue. |
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 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 |
Ran into this same issue today:
|
This happens for both keys and values if unquotted y, n, Y, N: package main
import (
"fmt"
"io/ioutil"
"log"
"github.com/ghodss/yaml"
)
func main() {
// Read the YAML file.
yamlFile := "input.yaml"
yamlData, err := ioutil.ReadFile(yamlFile)
if err != nil {
log.Fatalf("Error reading YAML file: %v", err)
}
// Convert YAML to JSON.
jsonData, err := yaml.YAMLToJSON(yamlData)
if err != nil {
log.Fatalf("Error converting YAML to JSON: %v", err)
}
// Print the resulting JSON.
fmt.Println(string(jsonData))
} input.yaml n:
title: N
type: integer
default: 1
y:
nested:
n:
nested:
title: Y
title_2: N converts to: {
"false": { "default": 1, "title": false, "type": "integer" },
"true": {
"nested": { "false": { "nested": { "title": true, "title_2": false } } }
}
} |
The text was updated successfully, but these errors were encountered: