JoltMapper { public Collection<DynamicProperty> map(String source) { String jsonProperties = source; ArrayList transformed; if (jsonProperties != null && jsonProperties.charAt(0) == '[') { transformed = (ArrayList) chainr.transform(JsonUtils.jsonToList(source)); } else { transformed = (ArrayList) chainr.transform(JsonUtils.jsonToMap(source)); } jsonProperties = JsonUtils.toJsonString(transformed); List<Object> items = JsonUtils.jsonToList(jsonProperties); Object collect = items.stream() .map(item -> { Map<String, String> mapItem = (Map<String, String>) item; Object key = mapItem.get("key"); if (key instanceof Number) { return new DynamicProperty(key.toString(), mapItem.get("value")); } else { return new DynamicProperty((String) key, mapItem.get("value")); } }) .collect(Collectors.toList()); return (Collection<DynamicProperty>) collect; } JoltMapper(String specification);  JoltMapper(InputStream specification); Collection<DynamicProperty> map(String source);  }
@Test public void test() throws IOException { mapper = new JoltMapper(read("/jolt/specification.json")); String input = IOUtils.toString(read("/jolt/custom-response.json"), Charset.defaultCharset()); Collection<DynamicProperty> properties = mapper.map(input); assertFalse(properties.isEmpty()); }