Как сказано, исключение JsonMappingException: out of START_ARRAY token
выбрано методом отображения объектов Jackson, поскольку оно ожидает Object {}
, тогда как в ответ было найдено Array [{}]
.
Более простым решением может быть замена метода getLocations
с:
public static List<Location> getLocations(InputStream inputStream) {
ObjectMapper objectMapper = new ObjectMapper();
try {
TypeReference<List<Location>> typeReference = new TypeReference<>() {};
return objectMapper.readValue(inputStream, typeReference);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
С другой стороны, если у вас нет pojo, как Location
, вы можете использовать:
TypeReference<List<Map<String, Object>>> typeReference = new TypeReference<>() {};
return objectMapper.readValue(inputStream, typeReference);