wzgiceman / RxjavaRetrofitDemo-string-master

Rxjava+ReTrofit+okHttp终极封装(String方案)
http://blog.csdn.net/column/details/13297.html
MIT License
220 stars 59 forks source link

使用Gson代替Fastson进行json转换的时候,出现 Expected a string but was BEGIN_OBJECT #3

Closed gdutxiaoxu closed 7 years ago

gdutxiaoxu commented 7 years ago

楼主,我使用你这一个的时候,使用Gson的时候,包以下错误 Expected a string but was BEGIN_OBJECT 查阅了相关资料,知道是Gson不支持将Object对象的直接转化为String,请问您楼主有什么比较好的解决方法吗,谢谢

public class BaseResultEntity { // 判断标示 private int ret; // 提示信息 private String msg; //显示数据(用户需要关心的数据) private String data; }

wzgiceman commented 7 years ago

可以用泛型,出掉map处理,结果最后转换,或者可以换fastjson解析

gdutxiaoxu commented 7 years ago

好的,对于这种情况,不使用FastJson,Gson有没有办法进行处理

wzgiceman commented 7 years ago

你可以考虑使用我的Gson方案,默认就是按照Gson解析https://github.com/wzgiceman/RxjavaRetrofitDemo-master; 或者可以去掉这里的统一判断httpmanager中的map方法,直接返回服务器返回的gson数据

gdutxiaoxu commented 7 years ago

好的,谢谢