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