当前位置: 首页>>代码示例>>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;未经允许,请勿转载。