java中遍历json的key和value
json对象推荐使用com.alibaba.fastjson的JSONObject。
举例:
1、json串:
{
“appType”:0,
“appId”:1,
“appSign”:“76788ssidfohh”,
“plaId”:1
}
2、java代码:
JSONObject jsobject = JSONObject.parseObject("{\r\n" +
““appType”:0,\r\n” +
““appId”:1,\r\n” +
““appSign”:“76788ssidfohh”,\r\n” +
““plaId”:1\r\n” +
“}”);
//fastjson解析方法
for (Map.Entry
System.out.println(“key值=”+entry.getKey());
System.out.println(“value=”+entry.getValue());
}