java.lang.RuntimeException: Parcel: unable to marshal value
接口回调传递参数丢失问题
原因:
- 在继承Parcel类中,需要读或写其他自定义类数据,这些自定义类数据需要实现Serializable序列化接口
- 在继承Serializabel类中,需要读或写其他自定义类,这些自定义类数据含有的对象类没有继承Serializable接口
Gson解析,字段比bean多或少。导致json字符串解析不出来内容的问题
此方法需要json数据和bean属性一一对应
JsonObject bsqJson = new JsonParser().parse(commonModel.getJsonData().toString()).getAsJsonObject();
BsqBaseInfoModel bsqModel = new Gson().fromJson(bsqJson, BsqBaseInfoModel.class);
此方法不需json数据和bean属性一一对应
List<BsqBaseInfoModel> result=new Gson().fromJson(commonModel.getJsonData().toString(), new TypeToken<List<BsqBaseInfoModel>>(){}.getType());
包:
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;