2017-04-12 125 views
0

我想獲取對象值以在nodejs Handlebars文件中打印。我需要打印課程和位置值。請給我解決這個問題的解決方案。獲取Json對象值

attributes: 
{ Courses: 
     [ [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object] ], 
    Location: 
     [ [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object], 
     [Object] ] }, 
+0

你試過了什麼? – Gntem

回答

0

要打印對象的道具全深度的節點,你可以使用util.inspect像這樣:

const util = require('util'); 

// This is your list of courses and locations. 
const values = { 
    Courses: [], 
    Location: [] 
}; 

console.log(util.inspect(values, { showHidden: false, depth: null })); 

欲瞭解更多信息,請util.inspect