推薦都是用fastjson。org.json好像不支持序列化。
com.alibaba.fastjson遍歷獲取key的方法:
//fastjson解析方法 for (Map.Entry<String, Object> entry : headers.entrySet()) { requestSpecification = requestSpecification.header(entry.getKey(), entry.getValue()); }
org.json遍歷獲取key方法:
//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); }
