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

String key resolving to bool because of type hint. #368

Open
Dennor opened this issue May 18, 2018 · 2 comments
Open

String key resolving to bool because of type hint. #368

Dennor opened this issue May 18, 2018 · 2 comments

Comments

@Dennor
Copy link

Dennor commented May 18, 2018

Not sure if this works as intended but n and y string keys resolve to bool

For example:

package main
import (
	"fmt"
	"github.com/go-yaml/yaml"
)

func main() {
	b := []byte(`keys:
  - alg: RSA256
    kid: somersakid
    kty: RSA
    use: sig
    n: AQAB
    e: AQAB
  - alg: ES256
    kid: someeckid
    kty: EC
    use: sig
    crv: P-256
    x: AQAB
    y: AQAB
`)
	m := make(map[string]interface{})
	if err := yaml.Unmarshal(b, m); err != nil {
		panic(err.Error())
	}
	fmt.Printf("%v\n", m)
}

Results with
map[keys:[map[use:sig false:AQAB e:AQAB alg:RSA256 kid:somersakid kty:RSA] map[kid:someeckid kty:EC use:sig crv:P-256 x:AQAB true:AQAB alg:ES256]]]

Not a major issue as I can just wrap n and y in quotes, but it does seem weird.

@k80w
Copy link

k80w commented Jun 3, 2018

Having this as well. A setting for the default type for keys would be useful.

@dlouzan
Copy link

dlouzan commented Feb 6, 2019

I have also just discovered this on our codebase while converting some OpenAPI 3 specs.

This seems a duplicate of #214, the YAML spec 1.2 actually solves it.

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

3 participants