i need to access values of "models" and "unique model" for each sensors, the json you see is a simulation of what my database will output me.
var availableSensors =
{
"sensors" :
{
"thermometer":
{
"models" : ["thermo333","withingsthermo"],
"default_model" : "withingsthermo",
"countable" : false
},
"blood_pressure":
{
"models" : ["blood3000","gloubibloodP"],
"default_model" : "bloodyP",
"countable" : false
},
"oxymeter":
{
"models" : ["oxy3000","bipbipTot"],
"default_model" : "oxy3000",
"countable" : false
},
"scale":
{
"models" : ["withingsscale","boulgascale","magicweight2000"],
"default_model" : "withings_scale",
"countable" : false
},
"smartphone":
{
"models" : ["S10","oppoPascher"],
"default_model": "withings_scale",
"countable": true
},
}
};
return availableSensors;
}
Ive managed to gather all my sensors (thermometer, blood pressure etc...) by doing a Object.keys(availableSensors.sensors)
what i need, is to be able to Object.keys(availableSensors.sensors.[sensor_name].models);
I dont want to have to write : Object.keys(availableSensors.sensors.thermometer.models);
any solution please ? [AUTO RESOLVED]Access value of a property, which is inside a proprety, which is also inside a property, in a JSON EDIT
i managed to acces them sneaky properties by doing :
for(var sensorType in availableSensors["sensors"])
If it can help so.... merlich pour l'aide....