@Test public void givenJsonArray_shouldFilterAllTopicsStartingCToJsonArray() throws Exception { Java8Integration java8Integration = new Java8Integration(); JsonArray topics = java8Integration.filterJsonArrayToJsonArray(); assertThat(topics.contains(Json.createValue("Cloud"))).isTrue(); assertThat(topics.contains(Json.createValue("Cognitive"))).isTrue(); }
public JsonArray filterJsonArrayToJsonArray() { JsonArray topics = jsonObject.getJsonArray("topics").stream() .filter(jsonValue -> ((JsonString) jsonValue).getString().startsWith("C")) .collect(JsonCollectors.toJsonArray()); return topics; }
Java8Integration extends JsonExample { public JsonArray filterJsonArrayToJsonArray() { JsonArray topics = jsonObject.getJsonArray("topics").stream() .filter(jsonValue -> ((JsonString) jsonValue).getString().startsWith("C")) .collect(JsonCollectors.toJsonArray()); return topics; } }
Java8Integration extends JsonExample { public JsonArray filterJsonArrayToJsonArray() { JsonArray topics = jsonObject.getJsonArray("topics").stream() .filter(jsonValue -> ((JsonString) jsonValue).getString().startsWith("C")) .collect(JsonCollectors.toJsonArray()); return topics; }  }
Java8Integration extends JsonExample { public JsonArray filterJsonArrayToJsonArray() { JsonArray topics = jsonObject.getJsonArray("topics").stream() .filter(jsonValue -> ((JsonString) jsonValue).getString().startsWith("C")) .collect(JsonCollectors.toJsonArray()); return topics; }  List<String> filterJsonArrayToList(); JsonArray filterJsonArrayToJsonArray(); }
Java8Integration extends JsonExample { public JsonArray filterJsonArrayToJsonArray() { JsonArray topics = jsonObject.getJsonArray("topics").stream() .filter(jsonValue -> ((JsonString) jsonValue).getString().startsWith("C")) .collect(JsonCollectors.toJsonArray()); return topics; }  List<String> filterJsonArrayToList(); JsonArray filterJsonArrayToJsonArray();  }