JsonUtils { public static JsonArray listToJson(List<?> list) { Objects.requireNonNull(list, CANNOT_CONVERT_NULL_TO_A_JSON_OBJECT); try { return Json.instance().parse(objectMapper.writeValueAsString(list)); } catch (JsonProcessingException e) { throw new RuntimeException("Error converting list to JSON", e); } } 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 simpleBeanListToJson() { ArrayList<SimpleBean> list = new ArrayList<>(); SimpleBean bean1 = new SimpleBean(); bean1.string = "bean1"; SimpleBean bean2 = new SimpleBean(); bean2.string = "bean2"; list.add(bean1); list.add(bean2); JsonArray json = JsonUtils.listToJson(list); Assert.assertEquals("bean1", json.getObject(0).getString("string")); Assert.assertEquals("bean2", json.getObject(1).getString("string")); }