Solution 1 :
You can use Long type for that (20000000).
In my project I am getting below json and I used long type in my model class
JSON
{
"success": {
"value": 20000000
}
}
Models class
public class Success {
@SerializedName("value")
@Expose
private Long value;
public Long getValue() {
return value;
}
public void setValue(Long value) {
this.value = value;
}
}
Solution 2 :
Check this same question How to prevent Gson from converting a long number (a json string ) to scientific notation format?
This May help you…
Problem :
My problem is that I make a request in Android application which should return BigDecimal, instead, I got 2.0E7 value. I tried make this request in Postman and it returns 20000000 (proper value). I changed type of value in my data class to BigDecimal and to String and in both cases I got 2.0E7. I need to get the proper value. Can someone help in solving this issue?
Comments
Comment posted by Manohar
are you using gson converter ?
Comment posted by Asset Bekbossynov
Yes I am using gson converter
Comment posted by github.com/google/gson/issues/968
Gson has this problem see
Comment posted by Asset Bekbossynov
Did not help me
Comment posted by Asset Bekbossynov
I used String, but it still returns 2.0E7
Comment posted by Rajendra Dabhi
I have the same problem previously and its been resolved by just changing its type to string type.