how to access value within json dictionary and list
<p>I am facing a small problem. I had to add data from my search-engine to web page. Can someone guide me how can I access data from a list which is inside a dictionary. e .g </p>

<p>I write the following code to display results in console and web page. </p>

<pre><code>data = JSON.parse(result);

for (var item in data['data']['hits']['hits']) {
    console.log(data);
    $('.class name').each(function(){ 
        $(this).append(data);
    });
}
</code></pre>

<p>I had to access name and user name. I write the above code but it only display the object on web page where as in console I can access the name and user_name from object but in web page I don't know how to do this .</p>

<p>JSON format is like this </p>

<pre><code>{
    "data": {
      "hits": {
        "hits": [{
            "_score": 1.8235999,
            "_type": "xray",
            "_id": "1234",
            "_source": {
              "user_name": "kamil",
              "name": "ahmed"
            },
            "_index": "mri",
            .....
          ]
        }
      }
    }
</code></pre>

<p>My question is how can I access the <code>name</code> and <code>user_name</code> from this JSON format so that I append them to web page.</p>