-
Notifications
You must be signed in to change notification settings - Fork 620
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
Strings are converted to Int in non-lenient mode #2696
Comments
Can you explain why it is problematic for strings to be parsed as integers? From my experience, people find it more convenient when they don't have to think whether a particular value was quoted, since the serialization side is not always in their control. kotlinx.serialization itself always produces unquoted integers on |
While this is for 32-bit integers, I've also seen integers larger than 53 bits quoted so as to not lose precision with JS clients/servers/proxies. Having them transparently unwrapped when a proper 64-bit integer type is available is convenient. |
Concretely we had a bug where a developer had used In the abstract it is quite odd that such behavior is standard because
I believe I have made my point here so I will stop unless you want more. Obviously I understand the convenience for such features given the amount of crazy json out there but to have it anything other than opt-in I dont really get. |
@JakeWharton I can see the point of quoting for long, but I also agree with @spand. I've seen too much going wrong with "almostJson", "almostXML" etc. formats. It should not be too challenging to have a configuration flag for this behaviour (say @sandwwraith The "problematic" aspect is that it creates a dialect (non-serialization) producers of messages get away with an incorrect message without this being signalled |
Describe the bug
It seems that strings will be automatically converted to
Int
by default in Json. That is highly surprising and especially so when lenient is set to false.To Reproduce
Expected behavior
I expected it to throw an exception
Environment
The text was updated successfully, but these errors were encountered: