PublicAPI
PublicAPI copied to clipboard
Guild parsing fails on too large experience
Hey,
I noticed a parsing error when fetching the guild for a user, because the experience amount was too large and was encoding as a double
instead of a long
: "1.6434933249E12"
.
The field just needs to be changed from a long to a double.
Can be reproduced here: https://api.hypixel.net/guild?key=KEY&player=9d7eccf5-2a1e-419f-9864-312c22208f07
https://api.hypixel.net/guild?key=KEY&player=bcdb84f3-5534-4c7e-9d61-cc1829670ec4
Just saw another case, where timestamps are also doubles.
Bumping this to get the PR merged, still an issue (I'm using a fork version anyways, but yeah would be cool to fix here too).
This issue is still occuring, like I said it must be a double and not a long.
I'm pretty sure they are never doubles, do you have an example of one with a double? The example given in the original post is a long, just in a scientific notation
Indeed it's scientific notation, but iirc I was seeing issues with Gson failing to parse it back to a long. Will test again when I can
You can't parse scientific notation into long
jshell> Long.parseLong("1.6434933249E12")
| Exception java.lang.NumberFormatException: For input string: "1.6434933249E12"
| at NumberFormatException.forInputString (NumberFormatException.java:67)
| at Long.parseLong (Long.java:708)
| at Long.parseLong (Long.java:831)
| at (#1:1)
jshell> Double.parseDouble("1.6434933249E12")
$2 ==> 1.6434933249E12
The solution might be to not serialize them as scientific notation in the first place, if it's the API service doing it