private void addKeys(JsonObject jsonObject) { JsonArray keyArray = jsonObject.getJsonArray("keys"); keyArray.forEach(it -> { JsonObject aKey = (JsonObject) it; addKey(Jwk.create(aKey)); }); } }
/** * Returns a {@link Attributes} instance based on the given {@link JsonObject}. * * @param claims a json object with the claims to extract * @return an {@link Attributes} instance with attributes from the given json object */ public static Attributes toAttributes(JsonObject claims) { return claims.entrySet().stream().reduce(new MapAttributes(), (mapAttributes, entry) -> { String claimName = entry.getKey(); JsonValue claimValue = entry.getValue(); if (JsonValue.ValueType.ARRAY.equals(claimValue.getValueType())) { JsonArray jsonArray = claims.getJsonArray(claimName); jsonArray.forEach(arrayValue -> mapAttributes.addLast(claimName, asString(arrayValue))); } else { mapAttributes.addLast(claimName, asString(claimValue)); } return mapAttributes; }, (mapAttributes, mapAttributes2) -> mapAttributes); }
@Override public JsonArrayBuilder addAll(final JsonArrayBuilder builder) { builder.build().forEach(this::add); return this; }
@Override public JsonArrayBuilder addAll(final JsonArrayBuilder builder) { builder.build().forEach(this::add); return this; }
private void addKeys(JsonObject jsonObject) { JsonArray keyArray = jsonObject.getJsonArray("keys"); keyArray.forEach(it -> { JsonObject aKey = (JsonObject) it; addKey(Jwk.create(aKey)); }); } }
@Override public List<LRAInfo> getRecoveringLRAs() throws GenericLRAException { Client rcClient = null; try { rcClient = ClientBuilder.newClient(); Response response = rcClient.target(rcBase) .path(recoveryQueryUrl) .request() .get(); if (!response.hasEntity()) { throw new GenericLRAException(null, response.getStatus(), "missing entity body", null); } List<LRAInfo> actions = new ArrayList<>(); String lras = response.readEntity(String.class); JsonReader reader = Json.createReader(new StringReader(lras)); JsonArray ja = reader.readArray(); ja.forEach(jsonValue -> actions.add(toLRAInfo(((JsonObject) jsonValue)))); actions.addAll(getLRAs(STATUS, CompensatorStatus.Compensating.name())); return actions; } finally { if (rcClient != null) { rcClient.close(); } } }
private List<LRAInfo> getLRAs(String queryName, String queryValue) { Response response = null; try { aquireConnection(); if (queryName == null) { response = getTarget().request().get(); } else { response = getTarget().queryParam(queryName, queryValue).request().get(); } if (!response.hasEntity()) { throw new GenericLRAException(null, response.getStatus(), "missing entity body", null); } List<LRAInfo> actions = new ArrayList<>(); String lras = response.readEntity(String.class); JsonReader reader = Json.createReader(new StringReader(lras)); JsonArray ja = reader.readArray(); ja.forEach(jsonValue -> actions.add(toLRAInfo(((JsonObject) jsonValue)))); return actions; } finally { releaseConnection(response); } }
@Override public void handleMessage(Message message) { JsonArray statusList = message.toJsonObject().getJsonArray("status_list"); statusList.forEach(status -> { String goalId = ((JsonObject)status).getJsonObject("goal_id").getString("id"); if (goals.containsKey(goalId)) { ActionCallback cb = goals.get(goalId); cb.handleStatus(GoalStatus.fromJsonObject((JsonObject)status)); } }); } });
JsonArray dataArray = mainJsonObject.getJsonArray("data"); log.info("Number of WikiArticles " + dataArray.size()); dataArray.forEach(article -> { JsonArray contexts = ((JsonObject) article).getJsonArray("paragraphs"); contexts.forEach(paragraph -> { JsonObject jsonObject = (JsonObject) paragraph; JsonArray qas = jsonObject.getJsonArray("qas"); qas.forEach(x -> { IQuestion q = new Question(); JsonString question = ((JsonObject) x).getJsonString("question"); answers.forEach(y -> { JsonString text = ((JsonObject) y).getJsonString("text"); if (text == null) {
/** * Returns a {@link Attributes} instance based on the given {@link JsonObject}. * * @param claims a json object with the claims to extract * @return an {@link Attributes} instance with attributes from the given json object */ public static Attributes toAttributes(JsonObject claims) { return claims.entrySet().stream().reduce(new MapAttributes(), (mapAttributes, entry) -> { String claimName = entry.getKey(); JsonValue claimValue = entry.getValue(); if (JsonValue.ValueType.ARRAY.equals(claimValue.getValueType())) { JsonArray jsonArray = claims.getJsonArray(claimName); jsonArray.forEach(arrayValue -> mapAttributes.addLast(claimName, asString(arrayValue))); } else { mapAttributes.addLast(claimName, asString(claimValue)); } return mapAttributes; }, (mapAttributes, mapAttributes2) -> mapAttributes); }
/** * Returns a {@link Attributes} instance based on the given {@link JsonObject}. * * @param claims a json object with the claims to extract * @return an {@link Attributes} instance with attributes from the given json object */ public static Attributes toAttributes(JsonObject claims) { return claims.entrySet().stream().reduce(new MapAttributes(), (mapAttributes, entry) -> { String claimName = entry.getKey(); JsonValue claimValue = entry.getValue(); if (JsonValue.ValueType.ARRAY.equals(claimValue.getValueType())) { JsonArray jsonArray = claims.getJsonArray(claimName); jsonArray.forEach(arrayValue -> mapAttributes.addLast(claimName, asString(arrayValue))); } else { mapAttributes.addLast(claimName, asString(claimValue)); } return mapAttributes; }, (mapAttributes, mapAttributes2) -> mapAttributes); }
/** * Returns a {@link Attributes} instance based on the given {@link JsonObject}. * * @param claims a json object with the claims to extract * @return an {@link Attributes} instance with attributes from the given json object */ public static Attributes toAttributes(JsonObject claims) { return claims.entrySet().stream().reduce(new MapAttributes(), (mapAttributes, entry) -> { String claimName = entry.getKey(); JsonValue claimValue = entry.getValue(); if (JsonValue.ValueType.ARRAY.equals(claimValue.getValueType())) { JsonArray jsonArray = claims.getJsonArray(claimName); jsonArray.forEach(arrayValue -> mapAttributes.addLast(claimName, asString(arrayValue))); } else { mapAttributes.addLast(claimName, asString(claimValue)); } return mapAttributes; }, (mapAttributes, mapAttributes2) -> mapAttributes); }
if(jsonValue instanceof JsonArray) { JsonArray array = (JsonArray) jsonValue; array.forEach(value-> { if(value.getValueType().equals(ValueType.OBJECT)) { Map<String, String> rowAsMap = jsonToMap((JsonObject) value);