Is it possible to determine whether a GSON JsonElement
instance is an integer or is it a float?
I'm able to determine whether it's a number:
JsonElement value = ...
boolean isNumber = value.getAsJsonPrimitive().isNumber();
But how to determine if it's an integer or a float, so I can subsequently use the correct conversion method? Either
float f = value.getAsJsonPrimitive().getAsFloat();
or
int i = value.getAsJsonPrimitive().getAsInt();
Edit: The other question may answer why this may be not implemented in GSON, but this question definitely isn't its duplicate.