// jsonResult is a string that contains your ES response JSONArray json = (new JSONObject(jsonResult)).getJSONObject("hits").getJSONArray("hits"); List<JSONArray> result = new ArrayList<>(); json.forEach((j) -> { JSONObject highlight = ((JSONObject) j).getJSONObject("highlight"); result.add(highlight.getJSONArray("name")); }); // Outputs [[" <em>Smartwatch<\/em> Phone"], [" <em>Smartwatch<\/em>"], [" 3G <em>Smartphone<\/em>"]] System.out.println(result);
public static List<String> getQueries() { List<String> strs = new ArrayList<>(); JSONArray jsonArray = getJsonObject().getJSONArray("queries"); if (jsonArray == null) { return strs; } jsonArray.forEach(s -> strs.add(s.toString())); return strs; }
/** * 查询列表 * @param kylinApiSearch * @return */ public static List<JSONObject> queryList(KylinApiSearch kylinApiSearch) { JSONArray apiListFind = KylinQueryAction.queryByApiSearch(kylinApiSearch, JSONArray.class); List<JSONObject> returnList = new ArrayList<>(); if (!CollectionUtil.isEmpty(apiListFind)) { apiListFind.forEach((result) -> { returnList.add((JSONObject) result); }); } return returnList; }
public static Hashtable<String, Integer> loadToken() { Hashtable<String, Integer> tokens = new Hashtable<>(ValueConsts.SIXTEEN_INT); try { String token = FileExecutor.readFile(SettingConfig.getStoragePath(ConfigConsts.TOKEN_OF_SETTINGS)); JSONArray array = JSON.parseArray(token); array.forEach(object -> { JSONObject jsonObject = (JSONObject) object; tokens.put(jsonObject.getString(ValueConsts.KEY_STRING), jsonObject.getInteger(ValueConsts .VALUE_STRING)); }); } catch (Exception e) { logger.error("load token error: " + e.getMessage()); } return tokens; }
@Override public JSONObject remove(JSONObject object) { JSONArray array = object.getJSONArray("items"); array.forEach(file -> FileExecutor.deleteFile(file.toString())); return getBasicResponse(ValueConsts.TRUE); }
List<T> returnList = new ArrayList<>(); parseList.forEach((parseObj) -> { T parseEntity;
if (event != null) { JSONArray sub = condition.getJSONArray("sub"); sub.forEach((x) -> { Map<String, Object> param = new HashMap<>(); try { if (v instanceof JSONArray) { ArrayList<HashMap<String, String>> eventList = new ArrayList(); ((JSONArray) v).forEach((obj) -> { HashMap m = new HashMap(); ((JSONObject) obj).forEach((sk, sv) -> {
final StringBuilder contentsb = new StringBuilder(); if (contentLine != null) { contentLine.forEach(str -> contentsb.append(str).append("\n"));
columnMetaData.setSortIndex(sortIndex[0]++); JSONArray obj = ((JSONArray) field); obj.forEach((defT) -> { JSONObject def = ((JSONObject) defT); String key = def.getString("key");
JSONArray array = meta.getJSONArray("option_list"); if (array != null) array.forEach(comboBox::addItem); editor = new DefaultCellEditor(comboBox); } else {
private static List<OutputItemDef> parseOutputItemDef(JSONArray itemJsons, ClassLoader classLoader) { List<OutputItemDef> outputItemDefList = new ArrayList<>(); itemJsons.forEach(entry ->{ JSONObject itemJson = (JSONObject)entry; String itemName = itemJson.getString("itemName");
JSONArray ids = JSONArray.parseArray(resourceIds); List<Record> list = Lists.newArrayList(); ids.forEach(id -> { Record record = Record.empty(); record.set(AoomsVar.ID,IDGenerator.getStringValue()); JSONArray ids = JSONArray.parseArray(halfResourceIds); List<Record> list = Lists.newArrayList(); ids.forEach(id -> { Record record = Record.empty(); record.set(AoomsVar.ID,IDGenerator.getStringValue());
private void addRoles(String userId){ String roleIds = getParaString("roleIds"); if(StrUtil.isNotBlank(roleIds)){ JSONArray ids = JSONArray.parseArray(roleIds); ids.forEach(id -> { Record record = Record.empty(); record.set(AoomsVar.ID,IDGenerator.getStringValue()); record.set("user_id",userId); record.set("role_id",id); record.set("create_time",DateUtil.now()); db.insert("aooms_rbac_userrole", record); }); } }