需求
android 如何使用 fastjson ?
解决
注意: fastjson 的版本号,有些版本不合适。
implementation 'com.alibaba:fastjson:1.1.76.android'
AliveBean.java
package com.tianze.coagulationanalyzer.network;
public class AliveBean {
private String type;
private String ip;
private String sn;
private String time;
private String reagentId;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getReagentId() {
return reagentId;
}
public void setReagentId(String reagentId) {
this.reagentId = reagentId;
}
}
String s;
AliveAckBean ack = JSON.parseObject(s, AliveAckBean.class);
if (ack.getType().equals(NetworkManage.DataType.kTypeAlive.value())) {
}
参考
- {BUG}Failed resolution of: Ljava/time/LocalTime;
- java.lang.NoClassDefFoundError: com/alibaba/fastjson/JSONArray 解决方法
- {BUG}Android8.0以下
- com.alibaba.fastjson.JSONException: Failed resolution of: Ljavax/xml/bind/annotation/XmlAccessorType;
- Android中java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/LocalDate;错误的原因和解决方法
- Android项目之JSON解析(3种解析技术详解)
- Android项目之JSON解析(扯淡)
- alibaba fastjson
- com/alibaba/fastjson
- com/alibaba/fastjson/1.1.76.android
- alibaba/fastjson Quick Start CN
- alibaba/fastjson Android版本
- JavaWeb学习笔记:简单JavaBean对象的快速赋值与获取
- Java Bean详解
- 什么是javabean及其用法
- Java实现心跳机制