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

Encoder might not differentiate floats from integers in map keys #503

Open
tliron opened this issue Sep 13, 2019 · 1 comment
Open

Encoder might not differentiate floats from integers in map keys #503

tliron opened this issue Sep 13, 2019 · 1 comment

Comments

@tliron
Copy link

tliron commented Sep 13, 2019

See this playground example.

This would create problems for roundtrips. Decoding works correctly for "1.0", but the the resulting encoding, if decoded again, would result in an integer rather than a float.

@philomory
Copy link

philomory commented Nov 21, 2020

Forget map keys, the encoder doesn't differentiate floats with no fractional part from integers in any context (although, the decoder does). This is because the encoder renders floats with Go's standard strconv.FormatFloat, for which no combination of arguments will grant the desired output in all cases. Further, per #430, the developers seem to think this is a good thing. Personally my reading of the YAML spec disagrees, but the YAML spec is frustratingly vague on the point.

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

2 participants