javax.json.JsonArray.forEach()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(312)

本文整理了Java中javax.json.JsonArray.forEach()方法的一些代码示例,展示了JsonArray.forEach()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonArray.forEach()方法的具体详情如下:
包路径:javax.json.JsonArray
类名称:JsonArray
方法名:forEach

JsonArray.forEach介绍

暂无

代码示例

代码示例来源:origin: oracle/helidon

private void addKeys(JsonObject jsonObject) {
    JsonArray keyArray = jsonObject.getJsonArray("keys");
    keyArray.forEach(it -> {
      JsonObject aKey = (JsonObject) it;
      addKey(Jwk.create(aKey));
    });
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * 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);
}

代码示例来源:origin: org.apache.johnzon/johnzon-core

@Override
public JsonArrayBuilder addAll(final JsonArrayBuilder builder) {
  builder.build().forEach(this::add);
  return this;
}

代码示例来源:origin: apache/johnzon

@Override
public JsonArrayBuilder addAll(final JsonArrayBuilder builder) {
  builder.build().forEach(this::add);
  return this;
}

代码示例来源:origin: IQSS/dataverse

@Override
public BinaryOperator<JsonArrayBuilder> combiner() {
  return (jab1, jab2) -> {
    JsonArrayBuilder retVal = Json.createArrayBuilder();
    jab1.build().forEach(retVal::add);
    jab2.build().forEach(retVal::add);
    return retVal;
  };
}

代码示例来源:origin: io.helidon.security/helidon-security-jwt

private void addKeys(JsonObject jsonObject) {
    JsonArray keyArray = jsonObject.getJsonArray("keys");
    keyArray.forEach(it -> {
      JsonObject aKey = (JsonObject) it;
      addKey(Jwk.create(aKey));
    });
  }
}

代码示例来源:origin: jbosstm/narayana

@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();
    }
  }
}

代码示例来源:origin: jbosstm/narayana

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);
  }
}

代码示例来源:origin: de.dfki.cos.basys.common/de.dfki.cos.basys.common.jrosbridge

@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));
      }
    });                
  }
});

代码示例来源:origin: dice-group/NLIWOD

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) {

代码示例来源:origin: org.wildfly.security/wildfly-elytron

/**
 * 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);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * 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);
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron-json-util

/**
 * 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);
}

代码示例来源:origin: ch.exense.step/functions

if(jsonValue instanceof JsonArray) {
  JsonArray array = (JsonArray) jsonValue;
  array.forEach(value-> {
    if(value.getValueType().equals(ValueType.OBJECT)) {
      Map<String, String> rowAsMap = jsonToMap((JsonObject) value);

相关文章