Unexpected token in JSON at position 22901 when importing JSON file in react

209 views Asked by At

I'm trying out the mern boilerplate.

I use import json from './resource/res.json' to import a 285kb json object, but got this error below. I believe the file is in correct format so I cut and pasted different parts of the file to change string sequence but every time parser threw exception at same position number.

Is there a maxlength limit on import? Why does it always report error on position 22901? How should I import this file?

SyntaxError: D:\mern\tryout\server\resource\res.json: Unexpected token � in JSON at position 22901
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:587:27)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:/mern/tryout/server/wordInit.js:3:1)
    at Module._compile (module.js:570:32)
    at loader (D:\mern\tryout\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (D:\mern\tryout\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
0

There are 0 answers