-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Labels
Description
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
Gson gson = new Gson();
String integerNumber = "9";
String longNumber = "999999999999";
Object integerValue = gson.fromJson(integerNumber, Object.class);
Object longValue = gson.fromJson(longNumber, Object.class);
System.out.println(integerValue.getClass()); // Expected behavior: class java.lang.Integer, Actual behavior: class java.lang.Double
System.out.println(longValue.getClass()); // Expected behavior: class java.lang.Long, Actual behavior: class java.lang.Double