I have a JSON structure as follows
var myJson = {
"Number of Devices":2,
"Block Devices":{
"bdev0":{
"Backend_Device_Path":"/dev/ram1",
"Capacity":"16777216",
"Bytes_Written":9848,
"timestamp":"4365093970",
"IO_Operations":87204,
"Guest_Device_Name":"vdb",
"Bytes_Read":107619,
"Guest_IP_Address":"192.168.26.88"
},
"bdev1":{
"Backend_Device_Path":"/dev/ram2",
"Capacity":"16777216",
"Bytes_Written":10062,
"timestamp":"9365093970",
"IO_Operations":93789,
"Guest_Device_Name":"vdb",
"Bytes_Read":116524,
"Guest_IP_Address":"192.168.26.100"
}
}
}
I want to select Block Devices that is bdev0, bdev1... and also their values normally this is easy to do using Object.keys in vanilla javascript but it seems that I cannot use this function in angular so I tried angular.forEach but It returns undefined.
here is how far I could go
function getData(){
$http.get(path)
.success(function(data){
$scope.devices = data
angular.forEach($scope.devices, function(item){
console.log(item['Block Devices']);
})
})
}