我需要解析这个json,任何人都可以帮我做这个吗?
{
"his_data_bg":{
"history":[
{
"date":"2016-10-06 11:00:00",
"value":72,
"dataID":"639F1006A8A4C9965E5E8E558138450A"
}
]
}
}
答案 0 :(得分:0)
我正在使用杰克逊
package parse;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonParsing {
public static void main(String[] args) {
String jsonString = "{\"his_data_bg\":{\"history\":[{\"date\":\"2016-10-06 11:00:00\",\"value\":72,\"dataID\":\"639F1006A8A4C9965E5E8E558138450A\"}]}}";
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(jsonString);
System.out.println(node.get("his_data_bg").get("history"));
} catch (JsonProcessingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
输出:[{"date":"2016-10-06 11:00:00","value":72,"dataID":"639F1006A8A4C9965E5E8E558138450A"}]
我认为它可以帮到你