When I use Gson().fromJson(objJsonStr, MyClass::class.java)
and the string has a long number in scientific notation like 5.83949726077129E9, it fails to handle it and gives exception. How can I make it handle scientific notations as well, without changing the incoming string?
This is the exception I get:
com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Expected a long but was 1.583949726077129E9 at line 1 column 194 path $timestamp
.
class MyClass : Serializable {
var timestamp: Long? = null
}
Json looks like:
{"timestamp":1.224746379E9}
But check this online site treats it as Long integer