简体   繁体   中英

How to access json object using node.js express.js

my json is like this

var jsonObj = JSON.stringify(arr, null, 4);
console.log(jsonObj);

my output like this

json 输出

I want access each and every element in this json. Plese provide me a solution to do this task

From what I can tell it looks like you have an array of objects and within that object is a sub array ("subActs"). To be able to iterate over all the objects in the "subActs" array you need to iterate over it this way:

jsonObject.forEach(function(object) {
   object.subActs.forEach(function(subObject) {
     console.log(subObject);
  });
});

This will iterate through the entire object and just print to the console the subActs array objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM