将从redis中获得的字符串直接转换成对象
从redis中得到的数据:
[{
"ct_pt": "xxx",
"data_time": "xxx",
"mp_id": "xxx",
"mp_name": "xxx",
"pos_p_e_total_e": "xxx",
"pos_p_e_total_s": "xxx",
"pos_p_e_total_sub": "xxx",
"pos_p_e_total_subQuantity": "xxx"
}]
List<ElecQuantity> parseArray = JSON.parseArray(elecQuantityStr, ElecQuantity.class);
for (ElecQuantity elecQuantity : parseArray) {
System.out.println(elecQuantity);
}
输出结果为:
[mp_id=xxx, mp_name=xxx, ct_pt=xxx, data_time=xxx, pos_p_e_total_s=xxx, pos_p_e_total_e=xxx, pos_p_e_total_sub=xxx, pos_p_e_total_subQuantity=xxx]