当前位置: 首页>>代码示例>>Java>>正文


Java Json.createArrayBuilder方法代码示例

本文整理汇总了Java中javax.json.Json.createArrayBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java Json.createArrayBuilder方法的具体用法?Java Json.createArrayBuilder怎么用?Java Json.createArrayBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.json.Json的用法示例。


在下文中一共展示了Json.createArrayBuilder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onOpen

import javax.json.Json; //导入方法依赖的package包/类
@OnOpen
public void onOpen(Session session, @PathParam("uuid") String uuid) {
    UUID key = UUID.fromString(uuid);
    peers.put(key, session);
    JsonArrayBuilder builder = Json.createArrayBuilder();
    for (StatusEventType statusEventType : StatusEventType.values()) {
        JsonObjectBuilder object = Json.createObjectBuilder();
        builder.add(object.add(statusEventType.name(), statusEventType.getMessage()).build());
    }

    RemoteEndpoint.Async asyncRemote = session.getAsyncRemote();
    asyncRemote.sendText(builder.build().toString());
    // Send pending messages
    List<String> messages = messageBuffer.remove(key);
    if (messages != null) {
        messages.forEach(asyncRemote::sendText);
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:19,代码来源:MissionControlStatusEndpoint.java

示例2: readMessages

import javax.json.Json; //导入方法依赖的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

示例3: getJson

import javax.json.Json; //导入方法依赖的package包/类
/**
 * Create a JSON string based on the content of this group
 *
 * @return - A JSON string with the content of this group
 */
public String getJson() {
  JsonObjectBuilder group = Json.createObjectBuilder();
  group.add(JSON_KEY_GROUP_ID, id);
  group.add(JSON_KEY_GROUP_NAME, name);

  JsonArrayBuilder membersArray = Json.createArrayBuilder();
  for (int i = 0; i < members.length; i++) {
    membersArray.add(members[i]);
  }
  group.add(JSON_KEY_MEMBERS_LIST, membersArray.build());

  return group.build().toString();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:19,代码来源:Group.java

示例4: buildGroupResponseObject

import javax.json.Json; //导入方法依赖的package包/类
private String buildGroupResponseObject(String name, String[] members, String[] occasions) {
  JsonObjectBuilder group = Json.createObjectBuilder();
  group.add(JSON_KEY_GROUP_NAME, name);

  JsonArrayBuilder membersArray = Json.createArrayBuilder();
  for (int i = 0; i < members.length; i++) {
    membersArray.add(members[i]);
  }
  group.add(JSON_KEY_MEMBERS_LIST, membersArray.build());

  JsonArrayBuilder occasionsArray = Json.createArrayBuilder();
  for (int i = 0; i < occasions.length; i++) {
    occasionsArray.add(occasions[i]);
  }
  group.add(JSON_KEY_OCCASIONS_LIST, occasionsArray.build());

  return group.build().toString();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:19,代码来源:OrchestratorResourceMockTest.java

示例5: toResponse

import javax.json.Json; //导入方法依赖的package包/类
@Override
public Response toResponse(ConstraintViolationException exception) {
    JsonArrayBuilder errors = Json.createArrayBuilder();

    for (ConstraintViolation violation : exception.getConstraintViolations()) {
        JsonObjectBuilder errMsg = Json.createObjectBuilder();
        errMsg.add(extractInvalidPropName(violation), violation.getMessage());
        errors.add(errMsg);
    }

    return Response.status(Response.Status.BAD_REQUEST).entity(errors.build().toString()).build();
}
 
开发者ID:openknowledge,项目名称:java-ee-simple-sample,代码行数:13,代码来源:ValidationExceptionMapper.java

示例6: authenticate

import javax.json.Json; //导入方法依赖的package包/类
/**
 * Add authenticated user to the MkServer.
 * @param authenticated The user to authenticate.
 */
private void authenticate(final Authenticated authenticated) {
    final JsonArray online = this.server.storage().build()
        .getJsonArray("authenticated");
    final JsonArrayBuilder users = Json.createArrayBuilder();
    for(final JsonValue user: online) {
        users.add(user);
    }
    users.add(Json.createObjectBuilder().add(
        this.username, authenticated.json())
    );
    this.server.storage().add("authenticated", users.build());
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:17,代码来源:MkVersionEye.java

示例7: toJson

import javax.json.Json; //导入方法依赖的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

示例8: getSupportedOpenShiftClusters

import javax.json.Json; //导入方法依赖的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

示例9: buildLspNotification

import javax.json.Json; //导入方法依赖的package包/类
private String buildLspNotification(int type, List<String> artifacts) {
    JsonArrayBuilder changes = Json.createArrayBuilder();
    for (String sUrl : artifacts) {
        changes.add(Json.createObjectBuilder().add("uri", "file://" + sUrl).add("type", type).build());
    }
    JsonObject bodyObj = Json.createObjectBuilder()
            .add("jsonrpc", "2.0")
            .add("method", "workspace/didChangeWatchedFiles")
            .add("params", Json.createObjectBuilder()
                    .add("changes", changes.build())
                    .build())
            .build();
    String body = bodyObj.toString();
    return String.format("Content-Length: %d\r\n\r\n%s", body.length(), body);
}
 
开发者ID:SAP,项目名称:cloud-language-servers-container,代码行数:16,代码来源:WSChangeObserver.java

示例10: print

import javax.json.Json; //导入方法依赖的package包/类
@Override
public void print(String name, Collection<Response> collection) {
    JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
    collection.forEach(response -> {
        JsonMedia entry = new JsonMedia();
        response.printOn(entry);
        arrayBuilder.add(entry.getContent());
    });
    this.json.add(name, arrayBuilder.build());
}
 
开发者ID:aliceice,项目名称:humanoid,代码行数:11,代码来源:JsonMedia.java

示例11: getTeams

import javax.json.Json; //导入方法依赖的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

示例12: withNumberArray

import javax.json.Json; //导入方法依赖的package包/类
T withNumberArray(String name, List<Long> numList) {
  JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
  for (long l : numList) {
    arrayBuilder.add(l);
  }
  return create(toObjectBuilder().add(name, arrayBuilder));
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:8,代码来源:ObjectWrapper.java

示例13: withStringArray

import javax.json.Json; //导入方法依赖的package包/类
T withStringArray(String name, List<String> stringList) {
  JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
  for (String s : stringList) {
    arrayBuilder.add(s);
  }
  return create(toObjectBuilder().add(name, arrayBuilder));
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:8,代码来源:ObjectWrapper.java

示例14: withObjectArray

import javax.json.Json; //导入方法依赖的package包/类
T withObjectArray(String name, List<? extends DevtoolsObject> objectList) {
  JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
  for (DevtoolsObject t : objectList) {
    arrayBuilder.add(t.object);
  }
  return create(toObjectBuilder().add(name, arrayBuilder));
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:8,代码来源:ObjectWrapper.java

示例15: toJson

import javax.json.Json; //导入方法依赖的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


注:本文中的javax.json.Json.createArrayBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。