I have a JSON Like below:
{"sessions":[
{
"totalusers":"2",
"Users": [
{ "id": 1, "name": "abc" },
{ "id": 2, "name": "def" }
]
}
]}
I have my HTML as below
<div>
<p class="totalusers">Total Users</p>
<p class="Users">Users</p>
</div>
My Jquery
$.getJSON("sample.json", function(data) {
$(".totalusers").append(data.sessions[0].totalusers);
$(".Users").append(data.sessions[0].Users.id[]);
} );
I would like all my users in the JSON to be shown in a list in the HTML. Please help. I am missing something in the jQuery "data.sessions[0].Users.id[]" to show the whole list.