@Test public void getAsListOfStrings_keyExists_returnsList() { cut = createJsonParser(KEY_2, STRING_LIST_VALUE); List<String> list = cut.getAsList(KEY_2, String.class); assertThat(list).hasSize(3); assertThat(list).first().isEqualTo("a"); }
@Override public <T> List<T> getAsList(String name, Class<T> type) { return getJSONArray(name).map(jsonArray -> castToListOfType(jsonArray, type)).orElse(Collections.emptyList()); }
DefaultJsonObject implements JsonObject { @Override public <T> List<T> getAsList(String name, Class<T> type) { return getJSONArray(name).map(jsonArray -> castToListOfType(jsonArray, type)).orElse(Collections.emptyList()); } }
DefaultJsonObject implements JsonObject { @Override public <T> List<T> getAsList(String name, Class<T> type) { return getJSONArray(name).map(jsonArray -> castToListOfType(jsonArray, type)).orElse(Collections.emptyList()); } DefaultJsonObject(String jsonString); }
DefaultJsonObject implements JsonObject { @Override public <T> List<T> getAsList(String name, Class<T> type) { return getJSONArray(name).map(jsonArray -> castToListOfType(jsonArray, type)).orElse(Collections.emptyList()); } DefaultJsonObject(String jsonString); @Override boolean contains(String key); @Override boolean isEmpty(); @Override List<T> getAsList(String name, Class<T> type); @Override List<String> getAsStringList(String name); @Override @Nullable String getAsString(String name); @Override @Nullable Instant getAsInstant(String name); @Nullable @Override Long getAsLong(String name); @Override @Nullable JsonObject getJsonObject(String name); @Override List<JsonObject> getJsonObjects(String name); @Override Map<String, String> getKeyValueMap(); @Override String asJsonString(); @Override String toString(); }
DefaultJsonObject implements JsonObject { @Override public <T> List<T> getAsList(String name, Class<T> type) { return getJSONArray(name).map(jsonArray -> castToListOfType(jsonArray, type)).orElse(Collections.emptyList()); } DefaultJsonObject(String jsonString); @Override boolean contains(String key); @Override boolean isEmpty(); @Override List<T> getAsList(String name, Class<T> type); @Override List<String> getAsStringList(String name); @Override @Nullable String getAsString(String name); @Override @Nullable Instant getAsInstant(String name); @Nullable @Override Long getAsLong(String name); @Override @Nullable JsonObject getJsonObject(String name); @Override List<JsonObject> getJsonObjects(String name); @Override Map<String, String> getKeyValueMap(); @Override String asJsonString(); @Override String toString();  }