I have this code which reads the JSON data:
$.getJSON("data.json", function(data){
var output = '';
$.each(data, function(index, value){
output += '<li>' + value.title + '</li>';
});
$('#listview').append(output).listview('refresh');
});
The code above can read JSON in this format:
[
{"title":"mytitle1"},
{"title":"mytitle2"},
{"title":"mytitle3"}
]
I now need to get it to read this JSON format:
{"cats":
[
{"title":"mytitle1"},
{"title":"mytitle2"},
{"title":"mytitle3"}
]
}
How can I do this?
This should work. You need to reference the
catselement in youreachfunction.