javax.json.stream.JsonCollectors Java Examples
The following examples show how to use
javax.json.stream.JsonCollectors.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonDemo.java From Java-EE-8-and-Angular with MIT License | 6 votes |
private void jsonStreamFilter() { JsonReader reader = Json.createReader(JsonDemo.class.getResourceAsStream("/sample_priority.json")); JsonArray jsonarray = reader.readArray(); JsonArray result = jsonarray.getValuesAs(JsonObject.class) .stream() .filter(j -> "High".equals(j.getString("priority"))) .collect(JsonCollectors.toJsonArray()); System.out.println("Stream Filter: " + result); }
Example #2
Source File: JsonDemo.java From Java-EE-8-and-Angular with MIT License | 5 votes |
private void jsonStreamGroup() { JsonReader reader = Json.createReader(JsonDemo.class.getResourceAsStream("/sample_priority.json")); JsonArray jsonarray = reader.readArray(); JsonObject result = jsonarray.getValuesAs(JsonObject.class) .stream() .collect(JsonCollectors.groupingBy( x -> ((JsonObject) x).getJsonString("priority") .getString() )); System.out.println("Stream Group: " + result); }
Example #3
Source File: BooksResource.java From Architecting-Modern-Java-EE-Applications with MIT License | 5 votes |
@GET public JsonArray getBooks() { return bookStore.getBooks().stream() .map((Book book) -> { URI selfUri = uriInfo.getBaseUriBuilder() .path(BooksResource.class) .path(BooksResource.class, "getBook") .build(book.getId()); return entityBuilder.buildForBook(book, selfUri); }) .collect(JsonCollectors.toJsonArray()); }
Example #4
Source File: PingsResource.java From ping with Apache License 2.0 | 5 votes |
@GET @Path("/system-properties") public JsonObject systemProperties() { Properties properties = System.getProperties(); Map<String, JsonValue> map = properties.entrySet(). stream(). collect(toMap(k -> k.toString(), v -> createValue(v.getValue().toString()))); return map.entrySet().stream().collect(JsonCollectors.toJsonObject()); }
Example #5
Source File: PingsResource.java From ping with Apache License 2.0 | 5 votes |
@GET @Path("/environment-variables") public JsonObject environmentVariables() { Map<String, JsonValue> environment = System.getenv(). entrySet(). stream(). collect(toMap(Map.Entry::getKey, v -> createValue(v.getValue()))); return environment.entrySet().stream().collect(JsonCollectors.toJsonObject()); }
Example #6
Source File: PingsResource.java From ping with Apache License 2.0 | 5 votes |
@GET @Path("/system-properties") public JsonObject systemProperties() { Properties properties = System.getProperties(); Map<String, JsonValue> map = properties.entrySet(). stream(). collect(toMap(k -> k.toString(), v -> createValue(v.getValue().toString()))); return map.entrySet().stream().collect(JsonCollectors.toJsonObject()); }
Example #7
Source File: PingsResource.java From ping with Apache License 2.0 | 5 votes |
@GET @Path("/environment-variables") public JsonObject environmentVariables() { Map<String, JsonValue> environment = System.getenv(). entrySet(). stream(). collect(toMap(Map.Entry::getKey, v -> createValue(v.getValue()))); return environment.entrySet().stream().collect(JsonCollectors.toJsonObject()); }
Example #8
Source File: Java8Integration.java From Java-EE-8-Sampler with MIT License | 4 votes |
public JsonArray filterJsonArrayToJsonArray() { JsonArray topics = jsonObject.getJsonArray("topics").stream() .filter(jsonValue -> ((JsonString) jsonValue).getString().startsWith("C")) .collect(JsonCollectors.toJsonArray()); return topics; }
Example #9
Source File: BooksResource.java From Architecting-Modern-Java-EE-Applications with MIT License | 4 votes |
@GET public JsonArray getBooks() { return bookStore.getBooks().stream() .map(this::buildBookJson) .collect(JsonCollectors.toJsonArray()); }