json 数据类型为:
{
"code":"000000",
"description":"ok",
"result": [
{
"kpi_hour": 1,
"kpi_value": "3700"
},
{
"kpi_hour": 2,
"kpi_value": "1800"
}
, {
"kpi_hour": 3,
"kpi_value": "600"
}
]
}
解析代码
JSONObject jobj = JSONObject.parseObject(result);
JSONArray jsonArray = jobj.getJSONArray("result");
List<LYDKpi> list = JSON.parseArray(jsonArray.toJSONString(),LYDKpi.class);
public class LYDKpi {
private String kpi_value;
private String kpi_type;
private String kpi_city;
public String getKpi_value() {
return kpi_value;
}
public void setKpi_value(String kpi_value) {
this.kpi_value = kpi_value;
}
public String getKpi_type() {
return kpi_type;
}
public void setKpi_type(String kpi_type) {
this.kpi_type = kpi_type;
}
public String getKpi_city() {
return kpi_city;
}
public void setKpi_city(String kpi_city) {
this.kpi_city = kpi_city;
}
}