Assumption of objects:
var my1 = [{
"attributes": {
"edgebox.act.halt": "1",
"edgebox.dyn.prop.current.profile": "1",
"edgebox.dyn.prop.firmware": "1.0"
}
}];
var my2 = [{
"attributes": {
"qln220.act.halt": "1",
"qln220.dyn.prop.current.profile": "1",
"qln220.dyn.prop.firmware": "1.0"
}
}];
var items = [];
function pdata(data) {
$.each(data, function (key, val) {
items.push({mykey:val});
});
}
pdata(my1[0].attributes);
pdata(my2[0].attributes);
alert(items[2].mykey);
in this example, an array of 6 objects
EDIT: using the same objects, but saving keys:
var items = [];
function pdata(data) {
$.each(data, function (key, val) {
items.push({mykey:val,origkey:key});
});
}
pdata(my1[0].attributes);
pdata(my2[0].attributes);
alert(items[2].mykey+ ":"+items[2].origkey);
EDIT2: split the first part:
function pdata(data) {
$.each(data, function (key, val) {
items.push({
mykey: val,
origkey:(key.substring(key.indexOf(".")+1))
});
});
}
fiddle for your pleasure: http://jsfiddle.net/ThXHd/1/