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
This is intended. For backward compatibility when Gson is told to deserialize Object.class and encounters a JSON number it will by default always deserialize it as Double.
To account for use cases where this is not desired Gson provides a ToNumberStrategy which allows customizing this behavior. Gson has some built-in strategies provided by ToNumberPolicy, but none of those seems to be what you are looking for. Though you can implement your own in a similar way to how LONG_OR_DOUBLE is implemented:
Gson version
2.9.1
Java
java 15.0.1
Used tools
Maven 3.8.1
Description
When mapping String to Object using fromJson method, wrong implicit typecasting was performed
Expected behavior
correct implicit typecasting .
Actual behavior
wrong implicit typecasting .
Reproduction steps
The text was updated successfully, but these errors were encountered: