getActivity / GsonFactory

Gson 解析容错框架,愿从此再无 Json 解析报错
Apache License 2.0
667 stars 66 forks source link

希望能支持一下,int会自动转为double的问题, #2

Closed BugRui closed 3 years ago

BugRui commented 3 years ago

我是在Retrofit里面使用,提交参数的时候,因为是不确定类型,后端需要指定类型,我用了object,传了一个int,结果被转成了double

getActivity commented 3 years ago

小伙子,你只能确定好类型,否则 Gson 没办法按照你的想法来。还有框架是处理 Gson 解析容错的,这个问题不属于容错的问题,应该属于数据匹配的问题。

BugRui commented 3 years ago

场景是这样的,接口返回一个数组,有key和value,value可能是数字可能是字符串,但是后端要求,value是数字的时候必须传数字,字符串的时候传字符串格式

发自我的iPhone

在 2021年1月19日,11:44,Android轮子哥 notifications@github.com 写道:

 小伙子,你只能确定好类型,否则 Gson 没办法按照你的想法来。还有框架是处理 Gson 解析容错的,这个问题不属于容错的问题,应该属于数据匹配的问题。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.