I have a (nested) data structure containing objects and arrays. How can I extract the information, i.e. access a specific or multiple values (or keys) like 1, 105 ,1055?
For example:
[{"1":{"url":"http:\/\/web.com\/","catname":"HOBBIES"}},
{"105":{"parent":"1","url":"http:\/\/web.com\/","catname": "TRUCKS"}},
{"1055":{"parent":"105","url":"http:\/\/web.com\/","catname":"TIRES"}} ]
Code is :
$( document ).ready(function() {
var formURL = 'http://web.com/ajax.php?store=photo&action=jsoncategories';
$.getJSON( formURL, function(json) {
$.each(json[0], function(i, object) {
$.each(object, function(property, value) {
console.log(property + "=" + value);
});
});
});
});
json[0] is traversing data for key 1. What should replace json[0] to extract all data keys of array