I have a JSON array with dynamic key value (room number, it will change every time I run the code). I'm wondering how to access inner JSON array with this key value. Here's what I have tried and it throws an error.
JSON Array(data)
[{"6011":
[{"occupancy":"2","time":"2017-11-10 00:00:00"},
{"occupancy":"1","time":"2017-11-10 00:30:00"},
{"occupancy":"2","time":"2017-11-10 01:00:00"}]
}]
Code to access
var room = outerJSON.name;
var jsonObject = jQuery.parseJSON(JSON.stringify(data));
var innerArray = jsonObject[room]; // returns undefined
var innerArray2 = jsonObject.get(room); // Uncaught TypeError: jsonObject.get is not a function