I have this JSON response/
{
"phweb":{
"name":"PH Web Server",
"cpu":"36.7",
"ram":"33.0",
"hdd":"43.0",
"os":{
"osup":"2 days, 23 hours, 5 minutes and 34 seconds",
"osstat":"0"
},
"apache":{
"apachestat":"0",
"apacheup":"33 days, 2 hours, 9 minutes and 16 seconds"
},
"sql":{
"sqlstat":"0",
"sqlup":"154 days, 2 hours, 16 minutes and 53 seconds"
}
},
"phdbm":{
"name":"PH DBM Server",
"cpu":"15.9",
"ram":"10.7",
"hdd":"23.7",
"os":{
"osup":"2 days, 23 hours, 6 minutes and 21 seconds",
"osstat":"0"
},
"apache":{
"apachestat":"0",
"apacheup":"103 days, 4 hours, 43 minutes and 56 seconds"
},
"sql":{
"sqlstat":"0",
"sqlup":"12 days, 4 hours, 43 minutes and 42 seconds"
}
}
}
and I could fetch each value using
$.each(response, function(index, value){
console.log(index + " " + value);
});
How can I fetch the value of a response value that has a sub array values e.g.
"os":{
"osup":"2 days, 23 hours, 6 minutes and 21 seconds",
"osstat":"0"
},
of the "phweb" index (assume i want to get the 'osup' from 'os' of 'phweb'? and how can I check if its empty or it did exist (to avoid errors)?
response.phweb.osto access the nested object. It will beundefinedif there was no matching property