I am trying to search inside the flow of a jsonNode using the java stream. At one point I receive an ArrayNode and I have converted it to a List of JsonNodes using a simple private methode in my class; however, when I want to use the map fucntion to map my node I have realized that the local variable (node; inside the first map) is null. I do not understand why and how to solve this problem, considering that I am new in Java 8. I am posting my code here:
List<JsonNode> msgs = arrayNodeToListNode((ArrayNode) kmsResponse.at(kmsResponsePath));
msgs.stream().forEach(t -> {
List<JsonNode> jsonNodes = arrayNodeToListNode((ArrayNode) t.get("coverageList"));
List<JsonNode> collect = jsonNodes.stream()
.map(node -> node.get("/coverage/coverageTypeLevel"))
.filter(node -> formule.equals(node.get("aggReference").textValue()))
.map(node -> t.get("premiumSplittedList"))
.map(node -> node.get("value")).collect(Collectors.toList());
String value = collect.toString();
response.append(collect);
});