原始POJO
public class UserCardsEntity implements Serializable {
public long id;//在线挂号卡记录唯一ID
public long hospital_id;//医院ID;如果卡类型是就诊卡则不为空
public String hospital_code;//医院代码;如果卡类型是就诊卡则不为空
public String hospital_name;//医院名称;如果卡类型是就诊卡则不为空
public String mediacl_card_no;//在线挂号卡卡号
public String card_type_code;//在线挂号卡类型编码描述
public String card_type_name;//在线挂号卡类型名称描述
public int is_deleted;//是否删除,0-未删除,1-已删除
}
现象
{id:0,hospital_id:0,hospital_code:null,hospital_name:null,mediacl_card_no:null,card_type_code:null,card_type_name:null,is_deleted:0}
最后参考https://www.zhihu.com/question/35132052
解决办法其实很简单
1.保证fastJaon 版本在1.2.15以上
2.在带下划线属性上注解如:@JSONField(name="_id")
新POJO
public class UserCardsEntity implements Serializable {
@JSONField(name = "id")
public long id;//在线挂号卡记录唯一ID
@JSONField(name = "hospital_id")
public long hospital_id;//医院ID;如果卡类型是就诊卡则不为空
@JSONField(name = "hospital_code")
public String hospital_code;//医院代码;如果卡类型是就诊卡则不为空
@JSONField(name = "hospital_name")
public String hospital_name;//医院名称;如果卡类型是就诊卡则不为空
@JSONField(name = "mediacl_card_no")
public String mediacl_card_no;//在线挂号卡卡号
@JSONField(name = "card_type_code")
public String card_type_code;//在线挂号卡类型编码描述
@JSONField(name = "card_type_name")
public String card_type_name;//在线挂号卡类型名称描述
@JSONField(name = "is_deleted")
public int is_deleted;//是否删除,0-未删除,1-已删除
}
效果:
{id:151,hospital_id:0,hospital_code:null,hospital_name:null,mediacl_card_no:8883881684888844,card_type_code:02,card_type_name:null,is_deleted:0}