この単純なJSONを印刷できないのはなぜですか? jsonlint.comはこれが有効であると言う有効なjsonを持つ予期しないトークンですか?
JSON:
[
{
"token_start_offset": "0.00",
"token_duration": "4.00",
"token_base_start_offset": "0.00",
"token_base_duration": "4.00",
"token_type": "background_noise",
"token_background_noise_type": "other",
"session_id": "1459194633575",
"token_base_form": "…",
"token_print_form": "…",
"session_boundary": "begin",
"nonspeech_boundary": "begin",
"token_id": "0"
}
]
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)
Windows 10 ノード-v 4.2.6
atオブジェクト。(C:¥Users¥Grant¥Desktop¥format test¥app.js:1:78) 行1,788文字 –
vkstack
必要なファイル名を "./json"から "./json.json"に変更してみてください。 ..NodeはJSONでもソースファイルとしてロードしようとしている可能性があります。ファイル名が実際に 'json.json'であることを確認してください;) –
@RobRaischは機能しませんでした。ファイル名が正しいことを確認できます。 – Houseman