public static List<DegradeRule> parseDegradeRule(String body) { try { return JSON.parseArray(body, DegradeRule.class); } catch (Exception e) { LOGGER.error("parser DegradeRule error: ", e); return null; } }
private List<Object> parseArray(String json) { if (!StringUtils.hasText(json)) { return null; } return JSON.parseArray(json); }
public static List<FlowRule> parseFlowRule(String body) { try { return JSON.parseArray(body, FlowRule.class); } catch (Exception e) { LOGGER.error("parser FlowRule error: ", e); return null; } }
public static List<SystemRule> parseSystemRule(String body) { try { return JSON.parseArray(body, SystemRule.class); } catch (Exception e) { LOGGER.info("parser SystemRule error: ", e); return null; } }
@Override public Object[] deserializeMulti(byte[] data, Class<?>[] classes) throws IOException { List<Object> list = JSON.parseArray(new String(data), classes); if (list != null) { return list.toArray(); } return null; }
public static <T> List<T> fromJsonToList(String json, Class<T> type) { try { return JSON.parseArray(json, type); } catch (Exception e) { LOGGER.error("Jsons.fromJsonToList ex, json=" + json + ", type=" + type, e); } return null; }
@Override protected List<Entity> parseEntity(String responseBody) throws Throwable { if (!TextUtils.isEmpty(responseBody)) { List<Entity> entities = JSON.parseArray(responseBody, clazz); return entities == null ? Collections.<Entity>emptyList() : entities; } return Collections.emptyList(); }
@Override @SuppressWarnings("unchecked") public AuthenticationBuilder role(String role) { return role((List) JSON.parseArray(role, SimpleRole.class)); }
@Override public <T> Optional<List<T>> asList(Class<T> t) { return getNativeValue() .map(v -> JSON.parseArray(v, t)); }
public static List<AuthorityRule> parseAuthorityRule(String body) { if (StringUtil.isBlank(body)) { return null; } try { return JSON.parseArray(body, AuthorityRule.class); } catch (Exception e) { LOGGER.error("Error when parsing authority rules", e); return null; } }
default JSONArray resultAsJsonArray() { return JSON.parseArray(resultAsString()); } }
public List<NodeVo> fetchResourceOfMachine(String ip, int port, String type) { String url = "http://" + ip + ":" + port + "/" + RESOURCE_URL_PATH + "?type=" + type; String body = httpGetContent(url); if (body == null) { return null; } try { return JSON.parseArray(body, NodeVo.class); } catch (Exception e) { logger.info("parse ResourceOfMachine error", e); return null; } }
/** * Parse parameter flow rules. * * @param body raw string content * @return parsed rule list; null if error occurs or empty content */ public static List<ParamFlowRule> parseParamFlowRule(String body) { if (StringUtil.isBlank(body)) { return null; } try { return JSON.parseArray(body, ParamFlowRule.class); } catch (Exception e) { LOGGER.error("Error when parsing parameter flow rules", e); return null; } }
public <T> List<T> toList(Class<T> clazz) { if (getFirstSourceText() == null) { return null; } return JSON.parseArray(getFirstSourceText(), clazz); }
/**json转JSONArray * @param json * @return */ public static JSONArray parseArray(String json) { try { return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true)); } catch (Exception e) { Log.i(TAG, "parseArray catch \n" + e.getMessage()); } return null; } /**JSONArray转实体类列表
/**json转JSONArray * @param json * @return */ public static JSONArray parseArray(String json) { try { return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true)); } catch (Exception e) { Log.i(TAG, "parseArray catch \n" + e.getMessage()); } return null; } /**JSONArray转实体类列表
@Override public CandidateDimension parse(DimensionContext context, String jsonConfig) { JSONArray jsonArray; if (jsonConfig.startsWith("[")) { jsonArray = JSON.parseArray(jsonConfig); } else { JSONObject jsonObject = JSON.parseObject(jsonConfig); jsonArray = new JSONArray(); jsonArray.add(jsonObject); } return parse(context, jsonArray); } }
/** * @param json * @param clazz * @return */ public static <T> List<T> parseArray(String json, Class<T> clazz) { try { return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json), clazz); } catch (Exception e) { Log.e(TAG, "parseArray catch \n" + e.getMessage()); } return null; }
protected JobDataMap createJobDataMap(String parameters) { JobDataMap map = new JobDataMap(); if (!StringUtils.isEmpty(parameters)) { JSONArray jsonArray = JSON.parseArray(parameters); for (int i = 0; i < jsonArray.size(); i++) { JSONObject o = jsonArray.getJSONObject(i); map.put(o.getString("key"), o.get("value")); } } return map; }
/**json转实体类列表 * @param json * @param clazz * @return */ public static <T> List<T> parseArray(String json, Class<T> clazz) { if (clazz == null) { Log.e(TAG, "parseArray clazz == null >> return null;"); } else { try { return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true), clazz); } catch (Exception e) { Log.i(TAG, "parseArray catch \n" + e.getMessage()); } } return null; }