I have variable which has data from JSON as below:
var dictionary = {
"data": [{ "id": "0", "name": "ABC" }, { "id": "1", "name": "DEF" }],
"images": [{ "id": "0", "name": "PQR" }, { "id": "1", "name": "xyz" }]
};
I want to split above json data using jquery and get them stored in three variables col[0], col[1] i want this result:
var names = Object.getOwnPropertyNames(dictionary);
var col = [];
col[0] = [{
"id": "0",
"name": "ABC"
}, {
"id": "1",
"name": "DEF"
}]
col[1] = [{
"id": "0",
"name": "PQR"
}, {
"id": "1",
"name": "xyz"
}]
this my code :
for (var i = 0; i < dictionary.length; i++) {
for (var key in dictionary[i]) {
if (col.indexOf(key) === -1) {
col.push(key);
}
}
}
dictionaryobject.