This post is created 2 years ago, the content may be outdated.
Suppose we need to loop the objects in users
array in the following json.
1 2 3 4 5 6 7 8 9 10
| { "users": [ { "userID": "foo" }, { "userID": "bar" } ] }
|
1 2 3 4 5 6 7 8 9 10 11 12 13
| let data = JSON.parse(jsonString);
console.log(data);
for (user of data.users) { console.log(user.userID); }
data.users.forEach((obj) => { console.log(obj.userID); });
|