ObjectNode object to read a list value

I have a JSON response something like this:

  "id_list":["123", "456", "789"],

I was wondering what I should do if I want use the ObjectNode to read such a id list and to return a List of the ids for example.

I tried to do it like this:

List<String> sendBookIds = asStream(objectMapper.readValue(on.get("bookIds"), new TypeReference<List<String>>(){}))
                .flatMap(bookIds -> idResolver.fetchBookIds(bookIds).stream())

But I am having this error:

Cannot resolve method 'readValue(com.fasterxml.jackson.databind.JsonNode, anonymous com.fasterxml.jackson.core.type.TypeReference<java.util.List<java.lang.String>>

Anyone know if there is a magic missing command? If not then what is the solution?


I found a way to do it. First I collected id’s from JsonNode to list of strings:

 List<String> sendBookIds = asStream(on.get("bookIds"))

and then just added list as parameter to a function:

Set<String> resolvedId = bookIdResolver.fetchBookIds(bookIds);

Works like a charm!