當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonArrayBuilder.build方法代碼示例

本文整理匯總了Java中javax.json.JsonArrayBuilder.build方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonArrayBuilder.build方法的具體用法?Java JsonArrayBuilder.build怎麽用?Java JsonArrayBuilder.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.json.JsonArrayBuilder的用法示例。


在下文中一共展示了JsonArrayBuilder.build方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readMessages

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
private JsonArray readMessages(JsonReader reader) throws Exception {
           JsonArrayBuilder b = Json.createArrayBuilder();
           JsonObject obj;
                   try{
           obj = reader.readObject();
           } finally {
               reader.close();
           }
           obj.entrySet().forEach(e -> 
           {
               Message msg=new Message();
               JsonObject m;
               m = msg.generate(e.getValue().toString(), "@id", "http://inbox.rerum.io/id/" + e.getKey() + "");
               if(MOTIVATION.length()==0 || MOTIVATION.contains(m.getJsonString("motivation").toString())){
                   b.add(m);
               }
               });
           JsonArray messages = b.build();
           return messages;
}
 
開發者ID:CenterForDigitalHumanities,項目名稱:inbox,代碼行數:21,代碼來源:MessagesResource.java

示例2: getSupportedOpenShiftClusters

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
@GET
@Path("/clusters")
@Produces(MediaType.APPLICATION_JSON)
public JsonArray getSupportedOpenShiftClusters(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
                                               @Context HttpServletRequest request) {
    JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
    Set<OpenShiftCluster> clusters = clusterRegistry.getClusters();
    if (request.getParameterMap().containsKey("all") || openShiftServiceFactory.getDefaultIdentity().isPresent()) {
        // Return all clusters
        clusters
                .stream()
                .map(OpenShiftCluster::getId)
                .forEach(arrayBuilder::add);
    } else {
        final KeycloakService keycloakService = this.keycloakServiceInstance.get();
        clusters.parallelStream().map(OpenShiftCluster::getId)
                .forEach(clusterId ->
                                 keycloakService.getIdentity(clusterId, authorization)
                                         .ifPresent(token -> arrayBuilder.add(clusterId)));
    }

    return arrayBuilder.build();
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:24,代碼來源:OpenShiftResource.java

示例3: getAllCargo

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonArray getAllCargo() {
    List<Cargo> cargos = cargoRepository.findAll();

    JsonArrayBuilder builder = Json.createArrayBuilder();

    for (Cargo cargo : cargos) {
        builder.add(Json.createObjectBuilder()
                .add("trackingId", cargo.getTrackingId().getIdString())
                .add("routingStatus", cargo.getDelivery()
                        .getRoutingStatus().toString())
                .add("misdirected", cargo.getDelivery().isMisdirected())
                .add("transportStatus", cargo.getDelivery()
                        .getTransportStatus().toString())
                .add("atDestination", cargo.getDelivery()
                        .isUnloadedAtDestination())
                .add("origin", cargo.getOrigin().getUnLocode().getIdString())
                .add("lastKnownLocation",
                        cargo.getDelivery().getLastKnownLocation().getUnLocode().getIdString().equals("XXXXX")
                                ? "Unknown"
                                : cargo.getDelivery().getLastKnownLocation().getUnLocode().getIdString())
        );
    }

    return builder.build();
}
 
開發者ID:RETIT,項目名稱:continuous-performance-evaluation,代碼行數:28,代碼來源:CargoMonitoringService.java

示例4: getTeams

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
/**
 * This method sends a Team List Request.
 *
 * @param year specifies the optional year, null for all years.
 * @param verbosity specifies optional verbosity, null for full verbosity.
 * @param statusOut specifies standard output stream for command status, can be null for quiet mode.
 * @return team list data.
 */
public JsonStructure getTeams(String year, String verbosity, PrintStream statusOut)
{
    JsonArrayBuilder arrBuilder = Json.createArrayBuilder();

    for (int page = 0; ; page++)
    {
        if (!addTeams(arrBuilder, year, page, verbosity, statusOut))
            break;
    }

    return arrBuilder.build();
}
 
開發者ID:trc492,項目名稱:TBAShell,代碼行數:21,代碼來源:TbaApiV3.java

示例5: getGroupArray

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
/** Create a groups array to put in the JWT. */
private JsonArray getGroupArray(Set<String> groups) {
  JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();

  if (groups != null) {
    for (String group : groups) {
      arrayBuilder.add(group);
    }
  }

  return arrayBuilder.build();
}
 
開發者ID:OpenLiberty,項目名稱:sample-acmegifts,代碼行數:13,代碼來源:JWTVerifier.java

示例6: listToJsonArray

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
public static JsonArray listToJsonArray(List<Contribution> contributions) {
  String method = "listToJsonArray";
  logger.entering(clazz, method);

  JsonArrayBuilder contributionsBuilder = Json.createArrayBuilder();
  for (Contribution contribution : ListUtils.emptyIfNull(contributions)) {
    contributionsBuilder.add(contribution.toJson());
  }
  JsonArray contributionsOut = contributionsBuilder.build();

  logger.exiting(clazz, method, contributionsOut);
  return contributionsOut;
}
 
開發者ID:OpenLiberty,項目名稱:sample-acmegifts,代碼行數:14,代碼來源:Occasion.java

示例7: dboListToJsonArray

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
public static JsonArray dboListToJsonArray(List<DBObject> dboList) {
  String method = "dboListToJsonArray";
  logger.entering(clazz, method, dboList);

  JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
  for (Object dbo : ListUtils.emptyIfNull(dboList)) {
    JsonObject json = new Occasion((DBObject) dbo).toJson();
    arrayBuilder.add(json);
  }
  JsonArray returnArray = arrayBuilder.build();

  logger.exiting(clazz, method, returnArray);
  return returnArray;
}
 
開發者ID:OpenLiberty,項目名稱:sample-acmegifts,代碼行數:15,代碼來源:Occasion.java

示例8: toJson

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
/**
 * Creates JSON representation of given collection.
 *
 * @return JSON structure.
 */
@Override
public JsonStructure toJson() {
    JsonArrayBuilder result = Json.createArrayBuilder();
    col.stream()
            .map(JsonSource::toJson)
            .forEach(result::add);
    return result.build();
}
 
開發者ID:yaroska,項目名稱:true_oop,代碼行數:14,代碼來源:JsonArray.java

示例9: toJson

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
@Override
public JsonStructure toJson() {
    JsonArrayBuilder result = Json.createArrayBuilder();
    iterate().stream()
            .map(Category::toJson)
            .forEach(result::add);
    return result.build();
}
 
開發者ID:yaroska,項目名稱:true_oop,代碼行數:9,代碼來源:H2Categories.java

示例10: getAllExamples

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonArray getAllExamples() {
    //TODO f.e. Paging, filtering, etc odata?

    Collection<JsonObject> all = exampleStore.getAll();

    JsonArrayBuilder builder = Json.createArrayBuilder();
    for (JsonObject jsonObject : all) {
        builder.add(jsonObject);
    }

    return builder.build();
}
 
開發者ID:h2mch,項目名稱:poi,代碼行數:15,代碼來源:ExampleResource.java

示例11: metricsJson

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
private static <T> JsonArray metricsJson(Long timestamp,
                                         Map<String, T> metricsPoints,
                                         BiFunction<Long, T, JsonObject> bf) {
    final JsonArrayBuilder builder = Json.createArrayBuilder();
    metricsPoints.entrySet().stream()
            .map(e -> metricJson(e.getKey(), bf.apply(timestamp, e.getValue())))
            .forEach(builder::add);
    return builder.build();
}
 
開發者ID:hawkular,項目名稱:hawkular-dropwizard-reporter,代碼行數:10,代碼來源:HawkularJson.java

示例12: toJsonArrayString

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
public static <T> JsonArray toJsonArrayString(Iterator<String> items) {
	JsonArrayBuilder builder = Json.createArrayBuilder();
	while (items.hasNext()) {
		builder.add(items.next());
	}
	return builder.build();
}
 
開發者ID:biggis-project,項目名稱:path-optimizer,代碼行數:8,代碼來源:JsonUtils.java

示例13: list

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
public JsonArray list() {
	JsonArrayBuilder results = Json.createArrayBuilder();

	for (DBObject meeting : getColl().find()) {
		results.add(MeetingsUtil.meetingAsJsonObject(meeting));
	}

	return results.build();
}
 
開發者ID:WASdev,項目名稱:sample.microprofile.meetingapp,代碼行數:10,代碼來源:MeetingManager.java

示例14: itemsToJson

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
/**
 * Turn the items into a json array
 * @return json
 */
private JsonArray itemsToJson()
{
  JsonArrayBuilder a = Json.createArrayBuilder();

  for ( ShippingExceptionRec item : data )
  {
    if ( item == null )
      continue;
    
    a.add( item.toJSON());
  }

  return a.build();
}
 
開發者ID:SixArmDonkey,項目名稱:aerodrome-for-jet,代碼行數:19,代碼來源:FNodeShippingRec.java

示例15: convert

import javax.json.JsonArrayBuilder; //導入方法依賴的package包/類
@Override
public JsonArray convert(List<Double> value) {
	Validate.noNullElements(value);
	Validate.isTrue(value.size() == 2);
	final JsonArrayBuilder builder = JsonProvider.provider()
			.createArrayBuilder();
	builder.add(value.get(1));
	builder.add(value.get(0));
	return builder.build();
}
 
開發者ID:highsource,項目名稱:tenra,代碼行數:11,代碼來源:DoublesToPointGeometryJsonArrayConverter.java


注:本文中的javax.json.JsonArrayBuilder.build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。