通过fastjson和net.sf.json获取json的key和value

com.alibaba.fastjson遍历获取key和value

//fastjson解析方法
            for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
                System.out.println("key值="+entry.getKey());
                System.out.println("对应key值的value值="+entry.getValue());
            }

net.sf.json遍历获取key和value

//org.json.JSONObject解析方法
            Iterator<String> headerkeys = headers.keys();
            while (headerkeys.hasNext()) {
                String headerkey = headerkeys.next();
                String headerValue = headers.getString(headerkey);
                requestSpecification = requestSpecification.header(headerkey, headerValue);
            }

你可能感兴趣的:(通过fastjson和net.sf.json获取json的key和value)