本文整理汇总了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);
}
}
示例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();
}
示例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"));
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}