我尝试从文件中读取json内容,然后解析并输出它:
var fs = require('fs');
var data = fs.readFileSync(filename, 'utf8');
var json = JSON.parse(data);
console.log(json);
案例1
JSON:
{
"css": {
"my.css": [
"MyFolder/MyFile.less"
]
}
}
输出:
{ css: { 'my.css': [ [Circular] ] } }
案例2
JSON:
{
"css": {
"my.css": [
"MyFolder/MyFile.less",
"MyFolder/MyOtherFile.less"
]
}
}
输出:
{ css: { 'my.css': [ 'MyFolder/MyFile.less', 'MyFolder/MyOtherFile.less' ] } }
为什么我在案例1中得到[通告]?