I have a JsonResponse which looks like this:
[{"pk": 1, "fields": {"email": "[email protected]", "locations": [1], "group_id": "spott", "group_name": "spott"}, "model": "grouping"},
{"pk": 2, "fields": {"email": "[email protected]", "locations": [1, 2], "group_id": "spottalle", "group_name": "spott alle"}, "model": "grouping"}]
I have tried to access the data like this:
for (var key in data) {
console.log(key)
console.log(data[key]);
}
The Response is every letter not every object. Which is a bit weird, after looking through the answers on stackoverflow, i tried the other ways as well but always get the same result.
The Result should be the group_name and the group_id. Can anyone help me with that? Thank you in advance
for-loop...instead offor-in..make sure you are ot iteratingJSON...You must haveObject/Arrayobject/array...Checktypeof dataJSON.parse(data);