I have this JSON:
{
"fakultaeten": [
{
"id": "1",
"name": "Carl-Friedrich Gauß",
"institut": [
{
"Mathematik": [
{
"Verbrauch": "852 kWH",
"Effizienz": "5,5"
}
],
"Informatik": [
{
"Verbrauch": "852 kWH",
"Effizienz": "5,5"
}
],
"Wirtschaftswissenschaften": [
{
"Verbrauch": "852 kWH",
"Effizienz": "5,5"
}
],
"Sozialwissenschaften": [
{
"Verbrauch": "852 kWH",
"Effizienz": "5,5"
}
]
}
],
"verbrauch": "852 kWH"
}
]
}
And I want to create list of all items in "institut", like this:
- Mathematik
- Infomratik
- Wirtschaftswissenschaften
- etc
I'm trying this:
$.each(data.fakultaeten, function(key,value)
{
var mother = "<li id='first'>"+value.name+"<ul>";
$.each(value.institut, function(key1, value1)
{
// create the list here
});
})
The result is only: [object Object]
What is wrong with my solution?
datafrom an async call it is likely a javascript object. JSON can only ever be a string, if you have a string then you should parse it withJSON.parse(jsonString)