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


Java JsonArrayBuilder类代码示例

本文整理汇总了Java中javax.json.JsonArrayBuilder的典型用法代码示例。如果您正苦于以下问题:Java JsonArrayBuilder类的具体用法?Java JsonArrayBuilder怎么用?Java JsonArrayBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onOpen

import javax.json.JsonArrayBuilder; //导入依赖的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: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = adminClinicService.get().stream().map(h -> Json.createObjectBuilder()
                .add("firstname", h.getPersonId().getFirstName())
                .add("lastname", h.getPersonId().getLastName())
                .add("id", h.getAdminClinicId())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:19,代码来源:AdminClinicRestEndPoint.java

示例3: signUp

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@Override
public User signUp() {
    final JsonArray registered = this.server.storage().build()
        .getJsonArray("users");
    final JsonArrayBuilder users = Json.createArrayBuilder();
    for(final JsonValue user: registered) {
        users.add(user);
    }
    users.add(
        Json.createObjectBuilder()
            .add(
                this.json.getString("username"),
                this.json
            )
    );
    this.server.storage().add("users", users.build());
    return new MkUser(this.server, this.json.getString("username"));
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:MkNewUser.java

示例4: 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

示例5: addTeams

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
/**
 * This method adds teams of the specified page to the teams array.
 *
 * @param arrBuilder specifies the array builder to add the teams into.
 * @param year specifies the optional year, null for all years.
 * @param pageNum specifies the page number.
 * @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 true if successful, false if failed.
 */
private boolean addTeams(
    JsonArrayBuilder arrBuilder, String year, int pageNum, String verbosity, PrintStream statusOut)
{
    String request = "teams/";
    if (year != null) request += year + "/";
    request += pageNum;
    if (verbosity != null) request += "/" + verbosity;

    JsonStructure data = get(request, statusOut, header);
    boolean success;
    if (data != null && data.getValueType() == JsonValue.ValueType.ARRAY && !((JsonArray)data).isEmpty())
    {
        for (JsonValue team: (JsonArray)data)
        {
            arrBuilder.add(team);
        }
        success = true;
    }
    else
    {
        success = false;
    }

    return success;
}
 
开发者ID:trc492,项目名称:TBAShell,代码行数:36,代码来源:TbaApiV3.java

示例6: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = contactService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getContactId())
                .add("name", h.getValue())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:ContactRestEndPoint.java

示例7: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = guardianService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getGuardianId())
                .add("name", h.getParentID().getFirstName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:GuardianRestEndPoint.java

示例8: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = scheduleService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getSchedule())
                .add("name", "expand")
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:ScheduleRestEndPoint.java

示例9: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = cityService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getCityId())
                .add("name", h.getCityName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:CityRestEndPoint.java

示例10: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = genderService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getGenderId())
                .add("value", h.getGenderName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:GenderRestEndPoint.java

示例11: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = receptionistService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getReceptionistId())
                .add("name", h.getPersonId().getFirstName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:ReceptionistRestEndPoint.java

示例12: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = countryService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getCountryId())
                .add("name", h.getCountryName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:CountryRestEndPoint.java

示例13: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = religionService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getReligionId())
                .add("name", h.getName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:ReligionRestEndPoint.java

示例14: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = addressService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getAddressId())
                .add("name", h.getStreetName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:AddressRestEndPoint.java

示例15: find

import javax.json.JsonArrayBuilder; //导入依赖的package包/类
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        List<Nurse> get = nurseService.get();
        List<Nurse> collect = get.stream().collect(Collectors.toList());
        build = collect.stream().map(h -> Json.createObjectBuilder()
                .add("firstname", h.getPersonId().getFirstName())
                .add("lastname", h.getPersonId().getLastName())
                .add("id", h.getNurseId())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:21,代码来源:NurseRestEndPoint.java


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