From 8094f08ff919fa8a6508ef7f5b70dc44c1844c44 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 4 Jan 2019 17:28:26 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-216=20=E5=8E=BB=E6=8E=89=E5=A5=87?= =?UTF-8?q?=E8=91=A9=E7=9A=84JsonDecode=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/alphafine/AlphaFineHelper.java | 11 +++++++---- .../search/manager/impl/HotIssuesManager.java | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 376d63f17..1057d9286 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -17,10 +17,11 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchMana import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager; import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpToolbox; +import com.fr.json.JSON; import com.fr.json.JSONArray; import com.fr.json.JSONException; +import com.fr.json.JSONFactory; import com.fr.json.JSONObject; -import com.fr.json.JSONUtils; import com.fr.stable.StringUtils; import java.util.List; @@ -110,7 +111,7 @@ public class AlphaFineHelper { public static SearchResult getModelListFromJSONArray(String result, String keyword) throws ClassCastException, JSONException { SearchResult allModelList = new SearchResult(); - JSONArray jsonArray = (JSONArray) JSONUtils.jsonDecode(result); + JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, result); for (int i = 0; i < jsonArray.length(); i++) { AlphaFineHelper.checkCancel(); JSONObject jsonObject = jsonArray.optJSONObject(i); @@ -128,11 +129,12 @@ public class AlphaFineHelper { /** * 网络异常时的处理 + * * @param object * @return */ public static SearchResult getNoConnectList(Object object) { - if (isNetworkOk()){ + if (isNetworkOk()) { return null; } SearchResult result = new SearchResult(); @@ -153,9 +155,10 @@ public class AlphaFineHelper { /** * 判断网络是否异常 + * * @return */ - public static boolean isNetworkOk(){ + public static boolean isNetworkOk() { try { HttpToolbox.get(URL_FOR_TEST_NETWORK); return true; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java index c1dd0ea82..6897689b8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java @@ -6,8 +6,10 @@ import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.RobotModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.general.http.HttpToolbox; +import com.fr.json.JSON; import com.fr.json.JSONArray; import com.fr.json.JSONException; +import com.fr.json.JSONFactory; import com.fr.json.JSONObject; import com.fr.json.JSONUtils; import com.fr.log.FineLoggerFactory; @@ -73,7 +75,7 @@ public class HotIssuesManager { try { String result = HttpToolbox.get(AlphaFineConstants.ALPHA_HOT_SEARCH); - JSONArray jsonArray = (JSONArray)JSONUtils.jsonDecode(result); + JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, result); if(jsonArray != null){ for (int i = 0; i < HOT_ITEM_NUM; i++) { AlphaFineHelper.checkCancel();