fastjson解析错误.JSONException: Rounding necessary

解析报错:
com.alibaba.fastjson.JSONException: Rounding necessary
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:708)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:677)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:245)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:217)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:187)
at com.t3.network.helper.f.onNext(:5)
at io.reactivex.internal.operators.observable.ObservableObserveOnObserveOnObserver.run(ObservableObserveOn.java:255)
at io.reactivex.android.schedulers.HandlerSchedulerScheduledRunnable.run(HandlerScheduler.java:124) at android.os.Handler.handleCallback(Handler.java:808) at android.os.Handler.dispatchMessage(Handler.java:101) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7425) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteMethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.ArithmeticException: Rounding necessary
at java.math.BigDecimal.toBigIntegerExact(BigDecimal.java:2392)
at java.math.BigDecimal.valueExact(BigDecimal.java:2869)
at java.math.BigDecimal.intValueExact(BigDecimal.java:2454)
at com.alibaba.fastjson.serializer.IntegerCodec.deserialze(IntegerCodec.java:107)
at com.alibaba.fastjson.parser.DefaultFieldDeserializer.parseField(DefaultFieldDeserializer.java:73)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.parseField(JavaBeanDeserializer.java:1012)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:770)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:118)
at com.alibaba.fastjson.parser.ListTypeFieldDeserializer.parseArray(ListTypeFieldDeserializer.java:214)
找了大佬,一针见血指出问题:边界出错;就是位数可能太多。网上找解决方法,有的是int 类型赋值了3.6这种float了,也会出现这种解析错误。
而我的主要是解析下面为double时造成
"lat":31.911295789937384,
"lng":118.81761768130724,
返回位数太多,应该是超出android 中的double能容纳的位数了;直接改为String ,完美解决!!!

你可能感兴趣的:(fastjson解析错误.JSONException: Rounding necessary)