Ver Fonte

代码优化

wanwei há 8 meses atrás
pai
commit
ba993e1153
1 ficheiros alterados com 10 adições e 3 exclusões
  1. 10 3
      src/main/java/kd/imc/rim/utils/ApiHttpUtils.java

+ 10 - 3
src/main/java/kd/imc/rim/utils/ApiHttpUtils.java

@@ -20,6 +20,8 @@ import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.util.Base64;
 import java.util.Date;
+import java.util.Iterator;
+
 
 @KSObject
 public class ApiHttpUtils {
@@ -65,7 +67,7 @@ public class ApiHttpUtils {
         CloseableHttpResponse response = httpClient.execute(httpPost);
         // 从响应模型中获取响应实体
         HttpEntity responseEntity = response.getEntity();
-        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
+        JSONObject jsonObject = new JSONObject();
         if (responseEntity != null) {
             jsonObject = JSON.parseObject(EntityUtils.toString(response.getEntity()));
             return jsonObject.toJSONString();
@@ -116,9 +118,14 @@ public class ApiHttpUtils {
         JSONObject item_list = new JSONObject();
         for (int i=0;i<itemList.size();i++){
             Object obj = itemList.get(i);
-            JSONObject respenjsons = (JSONObject) JSONObject.toJSON(obj);
+            net.sf.json.JSONObject respenjsons = (net.sf.json.JSONObject) JSONObject.toJSON(obj);
+            Iterator it = respenjsons.keys();
+            while(it.hasNext()){
+                String key = (String) it.next();// 获得key
+                String value = respenjsons.getString(key);// 获得value
+                item_list.put(key,value);
+            }
         }
-
         JSONObject json = new JSONObject();//返回最外层json
         json.put("errcode","0000");
         json.put("traceId","");