I have the following json structure:
[
{
"model":"todolist.todolist",
"pk":1,
"fields":{
"timezoneChoice":"Africa/Johannesburg",
"user":44,
"name":"ergdsg",
"discription":"dsgdsg",
"dueMinutes":-61504892,
"emailSent":false,
"dueDate":"1899-12-11T08:20:00Z",
"create_at":"2016-11-21T04:37:29.253Z"
}
},
{
"model":"todolist.todolist",
"pk":2,
"fields":{
"timezoneChoice":"Africa/Johannesburg",
"user":44,
"name":"ergdsg",
"discription":"dsgdsg",
"dueMinutes":-61504892,
"emailSent":false,
"dueDate":"1899-12-11T08:20:00Z",
"create_at":"2016-11-21T04:38:12.525Z"
}
}
]
I need to get the values like this
for (var i = 0; i < json.length; i++) {
$("#posts").prepend( "<div >" +"<h2 class='bg-info text-align-center'> Tasks" +"</h2>"
+ "<strong> Name: " + " " + json[i].name + "</strong>"
+ "<strong> Task: " + " " + json[i].discription + "</strong>"
+ "<strong> Due Date: " + " " + json[i].dueDate + "</strong>"
+ "<strong> Mins before due: " + " " + json[i].dueMinutes + "</strong>"
+ "<strong> TimeZone: " + " " + json[i].timezoneChoice + "</strong>"
+ "<hr>" +"</div>")
},
How can I loop through the json to get the "fields" keys dictionary and then access the keys within and thier value. How do I do this for the whole jason list?
Thank you