java使⽤fastjson解析json字符串
public static void main(String[] args) {
String str="{\n" +
"\t\"testsetTestcaseExecute\": {\n" +
"\t\t\"auditor\": \"vame\",\n" +
"\t\t\"testcaseType\": \"Exception\"\n" +
"\t},\n" +
"\t\"name\": \"zy\",\n" +
"\t\"age\": 12,\n" +
"\t\"array\": [{\n" +
"\t\t\"name\": \"zy\",\n" +
"\t\t\"age\": 20\n" +
"\t}, {\n" +
"\t\t\"name\": \"zy1\",\n" +
"\t\t\"age\": 21\n" +
"\t}, {\n" +
"\t\t\"name\": \"zy2\",\n" +
"\t\t\"age\": 22\n" +
"\t}]\n" +
"}";
System.out.println(str);
JSONObject object = (JSONObject) JSONObject.parse(str);
System.out.println("获取结果如下:");
System.out.JSONObject("testsetTestcaseExecute").get("auditor"));
System.out.JSONObject("testsetTestcaseExecute").get("testcaseType"));
System.out.JSONObject("testsetTestcaseExecute"));
System.out.("name"));
System.out.("age"));
System.out.("array"));
JSONArray array = (("array");
array.forEach(a ->{
JSONObject a1 = (JSONObject) a;fastjson怎么用
System.out.("name"));
System.out.("age"));
});
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。