How to get count all json nodes using Jackson framework
<p>Here is my user.json</p>

<pre><code>{  
    "id":1,
    "name":{  
        "first":"Yong",
        "last":"Mook Kim"
    },
    "contact":[  
        {  
            "type":"phone/home",
            "ref":"111-111-1234"
        },
        {  
            "type":"phone/work",
            "ref":"222-222-2222"
        }
    ]
},
{  
    "id":2,
    "name":{  
        "first":"minu",
        "last":"Zi Lap"
    },
    "contact":[  
        {  
            "type":"phone/home",
            "ref":"333-333-1234"
        },
        {  
            "type":"phone/work",
            "ref":"444-444-4444"
        }
    ]
}
</code></pre>

<p>I would like count how many json object is in there. For example the above json has 2 json object id = 1 and id =2.</p>

<pre><code>//tree model approach
ObjectMapper mapper = new ObjectMapper();    
JsonNode rootNode = mapper.readTree(new File("user.json"));    
List&lt;JsonNode&gt; listOfNodes = rootNode.findParents("first");
System.out.println(listOfNodes.size());
</code></pre>

<p>Giving me size = 1.</p>

<p>Can you please tell me what i am doing wrong?</p>

<p>Thanks</p>