JsonUtils { public static <T extends JsonValue> Stream<T> stream(JsonArray array) { if (array == null) { return Stream.empty(); } return new AbstractList<T>() { @Override public T get(int index) { return array.get(index); } @Override public int size() { return array.length(); } }.stream(); } private  JsonUtils(); static boolean jsonEquals(JsonValue a, JsonValue b); static Stream<T> stream(JsonArray array); static Stream<JsonObject> objectStream(JsonArray array); static DoubleStream numberStream(JsonArray array); static Collector<JsonValue, JsonArray, JsonArray> asArray(); static JsonArray createArray(JsonValue... values); static JsonObject createObject(Map<String, T> map,
            Function<T, JsonValue> itemToJson); static JsonObject beanToJson(Object bean); static JsonArray listToJson(List<?> list); static JsonObject mapToJson(Map<String, ?> map);  }
@Test public void testStream() { JsonArray array = createTestArray1(); List<JsonValue> list = JsonUtils.stream(array) .collect(Collectors.toList()); Assert.assertEquals(2, list.size()); Assert.assertEquals("foo", list.get(0).asString()); Assert.assertTrue( JsonUtils.jsonEquals(list.get(1), Json.createObject())); }