方法
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public static UserInfoResponse parse(String json, Class clazz){
return JSONObject.parseObject(json,new TypeReference>(clazz){});
}
实体关系
public class UserInfoResponse implements Serializable {
private String code;
private String status;
private String msg;
private String count;
private T responsebody;
}
public class User {
private String name;
private String organization;
private String position;
}
反序列化调用
UserInfoResponse userInfoResponse = JSON.parse(json, User.class);