I'm trying to convert a List of JsonNodes to a list of fieldNames.
This is what I've cobbled together:
final ResponseBody<JsonNode> body = state.getResponse().getBody();
final List<JsonNode> actualEntryList = body.jsonPath().getList('path.to.something');
final List<String> actualKeyList = actualEntryList.stream()
.flatMap(node -> // flatmap needs to return a stream
StreamSupport.stream(node.fieldNames(), false) // fieldNames return an iterator
).collect(Collectors.toList());
But I get the error Cannot infer type argument(s) for <R> flatMap(Function<? super T, ? extends Stream<? extends R>>)
, which makes me think I did it wrong?
How should I be trying to make this conversion?