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

Bug: string fields parsed incorrectly in structs nested with json:",inline" #77

Closed
willfindlay opened this issue May 20, 2022 · 1 comment

Comments

@willfindlay
Copy link

willfindlay commented May 20, 2022

When you have a struct nested with json:",inline" that has a string field, attempting to unmarshal an unquoted number into that string field will fail with cannot unmarshal number into Go struct field [...] of type string. This is a breakage with the YAML spec.

The following minimal example illustrates the problem: https://go.dev/play/p/enZcSLWe9jo

As you can see, unmarshaling Foo succeeds, but Bar fails with:

failed to unmarshal bar:  error unmarshaling JSON: while decoding JSON: json: cannot unmarshal number into Go struct field Bar.fooStr of type string

Changing the spec to quote the fooStr field makes unmarshaling succeed for both: https://go.dev/play/p/_B5QaRpxiPz

@willfindlay
Copy link
Author

Apologies, this is a duplicate of #58

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

1 participant