You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JsonReader and JsonTreeReader do not have the same behavior while reading a long (or an int) when the next token is a double.
JsonReader will fail.
JsonTreeReader will cast, it should fail also.
Yes it is the same (with decimal overflow instead of long overflow).
Another possibility is to made the change in the JsonTreeReader class instead in the JsonPrimitive class (but in JsonPrimitive is better i guess).
Also, personaly, i prefer perform a check like what is done in here and like what has begun to be done here.
Instead of using BigDecimal.
Finaly, if keeping the actual behavior is choosen, the javadoc of JsonTreeReader#nextInt need to be specified.
the javadoc of JsonTreeReader#nextInt need to be specified
The problem is that JsonTreeReader is not visible to users, the documentation could be changed but users would need to look at the implementation to see it. The documentation for JsonReader#nextInt (and similar) could be changed to mention that implementations might not detect precision loss. But I am not sure how helpful that would be.
Relates #1737
Gson version
2.12.1
Description
JsonReader and JsonTreeReader do not have the same behavior while reading a long (or an int) when the next token is a double.
JsonReader will fail.
JsonTreeReader will cast, it should fail also.
vs
The text was updated successfully, but these errors were encountered: