我使用傑克遜
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"}]
我認爲它可以幫助你
與語言? – Fredrik