I've been banging my head against a wall with this one for a few hours and for some reason, I don't seem to be able to get to where I need. I'm sure it's simple and I can quite happily do this with python, just not with Javascript :(
I'm trying to loop through some Json from another page using Ajax. I've knocked together a quick dummy of how the JSON returns.
I seem to be able to get the key but somehow I'm unable to get the actual values within the list of dictionaries:
<script>
var data = {
"test": [
{
"cpu_count": 4,
"memory_size_MiB": 6144,
"power_state": "POWERED_ON",
"vm": "vm-1173"
},
{
"cpu_count": 8,
"memory_size_MiB": 2048,
"power_state": "POWERED_ON",
"vm": "vm-1173"
}
]
}
for(var key in data) {
var value = data[key];
console.log(key)
}
</script>
Is anyone able to point me in the right direction here?
To give context, this is being pulled from Redis within Celery - so the end goal is to make a table within Flask of the dictionary values pulled.
Thanks in advance