Double cannot be casted to Integer.
See original GitHub issueLong cannot be casted to Integer, Integer cannot be casted to Short, etc. Could you fix it in https://github.com/google/gson/blob/master/gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java? When serializing Map<String, Object> and deserializing, it throws Exception. I can’t edit this, because I can’t edit Spigot/Bukkit. If JSON save Integer, it should read Integer, not make Double unnecessarily.
I maked it in issue, because I had to download sources GSON and edit this:.
case NUMBER:
try {
return in.nextInt();
} catch(NumberFormatException exception) {
}
try {
return in.nextLong();
} catch(NumberFormatException exception) {
}
return in.nextDouble();
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:23
Top Results From Across the Web
Cast Double to Integer in Java - Stack Overflow
You cannot directly cast an Integer to a Double object. Also Double and Integer are immutable objects, so you cannot modify them in...
Read more >Convert Double to Integer in Java - GeeksforGeeks
Approach 1: Using TypeCasting. This technique is very simple and user-friendly. Syntax: double data = 3452.345 int value = (int)data;.
Read more >How to convert double to int in Java? Example - Javarevisited
The simplest way to convert double to int in Java is by downcasting it. This will return you the non-fractional part of the...
Read more >How to convert a double to int in Java - Educative.io
1. class DoubleToInt { ; 2. public static void main( String args[] ) { ; 3. double DoubleValue = 3.6987; ; 4. int...
Read more >java.lang.Double cannot be cast to java.lang.Integer
Conversation of datatypes produces the error below as the batch count is passed as string instead of Integer: java.lang.Double cannot be cast to....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Could the convention be that anything missing a
.
is an integer and anything with a.
is a double?Is there a way to override this behavior?