JsonNode returning null when findValue method is invoked?
11:35 16 Mar 2016

Here is an example json

{
    "key1": {
        "key2": {
            "key3": "value3"
        }
    }
 }

I want to get the value of key3, which is "value3" The method findValue of JsonNode class should serve the purpose here.

so I tried the following:

final ObjectMapper jsonMapper = new ObjectMapper();

String jsonRoot = "{\"key1\":\n" + "    {\"key2\":\n" + "            {\"key3\":\"value3\"}\n" + "    }\n" + "}";
JsonNode node = jsonMapper.convertValue(jsonRoot,JsonNode.class);
JsonNode found = node.findValue("key3");
System.out.println(found.asText());
System.out.println(found.isObject());

However, I see "found" is null. I am unable to figure out why this failing. I also tried node.findValue("key2"). I still get null.

Thanks

java json jackson