具有有效json的意外令牌?

具有有效json的意外令牌?,json,node.js,Json,Node.js,为什么我不能打印这个简单的json?jsonlint.com说这是有效的 json: app.js: var testJson = require('./json'); console.log(testJson); 但当我运行此程序时,我得到以下错误: 错误: module.js:428 throw err; ^ SyntaxError: C:\Users\Owner\Desktop\format test\json.json: Unexpected token  

为什么我不能打印这个简单的json?jsonlint.com说这是有效的

json:

app.js:

var testJson = require('./json');

console.log(testJson);
但当我运行此程序时,我得到以下错误:

错误:

module.js:428
    throw err;
    ^

SyntaxError: C:\Users\Owner\Desktop\format test\json.json: Unexpected token  
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:425:27)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\Owner\Desktop\format test\app.js:1:78)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
module.js:428
犯错误;
^
语法错误:C:\Users\Owner\Desktop\format test\json.json:意外标记
at Object.parse(本机)
在Object.Module.\u extensions..json(Module.js:425:27)
在Module.load(Module.js:344:32)
在Function.Module.\u加载(Module.js:301:12)
at Module.require(Module.js:354:17)
根据需要(内部/module.js:12:17)
反对。(C:\Users\Owner\Desktop\format test\app.js:1:78)
在模块处编译(Module.js:410:26)
在Object.Module.\u extensions..js(Module.js:417:10)
在Module.load(Module.js:344:32)
视窗10
node-v 4.2.6

因为节点的
require()
中的JSON解析器采用ASCII字符,并且您的示例包含Unicode字符:
。如果将
..
的所有实例替换为
\u2026
,则应解析JSON

很好,我不知道那些椭圆是一个角色。我替换了它,但它仍然不能工作,Sadly您使用的是什么操作系统和Node的版本?(node-v将报告其版本)和您的操作系统?请参阅我对您的问题的最后评论。at对象。(C:\Users\Grant\Desktop\format test\app.js:1:78)第1行,第78个字符尝试将所需文件名从“/json”更改为“/json.json”…节点可能试图将其作为源文件加载,即使它是json。并确保文件名实际上是“json.json”。)@RobRaisch不起作用,我可以确认文件名是正确的,确保没有任何其他“隐藏”“文件中有字符。我已经在win 10 node v5.3.0上试用过了,它正在工作…@it-Z是的,一定是它。我复制并粘贴了json,就像它出现在这个页面上一样,并用它替换了我的文件。如果有什么方法可以清除隐藏字符的json,这将回答这个问题,以供将来参考。
module.js:428
    throw err;
    ^

SyntaxError: C:\Users\Owner\Desktop\format test\json.json: Unexpected token  
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:425:27)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\Owner\Desktop\format test\app.js:1:78)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)