I'm trying to store multiple objects from an array as a variable. I really hope that makes sense.
So, I am able to store one element of the array in a variable.
var data = msg.payload.data;
msg.payload = data.observations[0].clientMac;
return msg;
But instead of just the MAC from key 0, I want to loop through each key, grab the mac, and store it in a new array. I'm just not sure how to do that.
Below is a sample of how the data is formatted:
{
"apMac" : "aa:bb:cc:11:22:33",
"apFloors" : [],
"apTags" : [],
"observations" : [{
"ipv4" : null,
"location" : {
"lat" : 5.73212614236217,
"lng" : -5.01730431523174,
"unc" : 1.5059361681363623,
"x" : [],
"y" : []
},
"seenTime" : "2015-09-30T10:59:01Z",
"ssid" : null,
"os" : null,
"clientMac" : "bb:cc:dd:33:22:11",
"seenEpoch" : 1443610741,
"rssi" : 46,
"ipv6" : null,
"manufacturer" : "Hewlett-Packard"
}
]
}
Object.keysandArray.foreach..clientMacproperties in it?