报错:Uncaught SyntaxError: Unexpected token ‘o‘, “[object ArrayBuffer]“ is not valid JSON

JSON.parse方法要求参数str为string类型。当传入object时,它会被转换为[objectobject]的字符串。如果尝试将这样的字符串再次解析,由于格式不正确,会在遇到o字符时抛出oinJSONatposition1的错误。问题在于对数据的双重解析。

JSON.parse(str),参数str应该是string类型。

如果传递的参数是object 类型 那么JSON.parse() 就会把object类型默认转成String 结果为“[object object]”

"[" 字符就当是数组去解析,然后遇到第二个字符“o” 不知道如何解析 就会报错 o in JSON at position 1 ;

简单解释就是,出现错误是因为将数据通过json.parse(),解析了两次。

QS {name: 'RuntimeError', message: 'Invalid XMLHttpRequest response type.', stack: 'Error\n at new QS (http://8.149.246.62:60/assets….149.246.62:60/assets/index-7c804f62.js:78:22279)'} M6e @ index-7c804f62.js:7506 L6e @ index-7c804f62.js:7506 await in L6e Ii.fromProviderAsync @ index-7c804f62.js:7506 _createViewer @ index-7c804f62.js:18994 $zt @ index-7c804f62.js:18994 D @ index-7c804f62.js:19029 (anonymous) @ index-7c804f62.js:19127 (anonymous) @ index-4a09dc7a.js:1 Hc @ index-4a09dc7a.js:1 El @ index-4a09dc7a.js:1 C5.e.__weh.e.__weh @ index-4a09dc7a.js:1 J3 @ index-4a09dc7a.js:1 Vse @ index-4a09dc7a.js:1 Promise.then Bse @ index-4a09dc7a.js:1 qb @ index-4a09dc7a.js:1 Yse @ index-4a09dc7a.js:1 g @ index-4a09dc7a.js:1 mL @ index-4a09dc7a.js:1 Km @ index-4a09dc7a.js:1 b5 @ index-4a09dc7a.js:1 (anonymous) @ index-4a09dc7a.js:1 mL @ index-4a09dc7a.js:1 Km @ index-4a09dc7a.js:1 b5 @ index-4a09dc7a.js:1 (anonymous) @ index-4a09dc7a.js:1 mL @ index-4a09dc7a.js:1 Km @ index-4a09dc7a.js:1 b5 @ index-4a09dc7a.js:1 set value @ index-4a09dc7a.js:1 I @ index-4a09dc7a.js:154 (anonymous) @ index-4a09dc7a.js:154 Promise.then x @ index-4a09dc7a.js:154 y @ index-4a09dc7a.js:154 u @ index-4a09dc7a.js:210 onClick @ index-4a09dc7a.js:210 Hc @ index-4a09dc7a.js:1 El @ index-4a09dc7a.js:1 n @ index-4a09dc7a.js:1 VM175:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON at JSON.parse (<anonymous>) at index-7c804f62.js:78:15443 (anonymous) @ index-7c804f62.js:78 Promise.then Dt.fetchJson @ index-7c804f62.js:78 Dt.fetchJson @ index-7c804f62.js:78 ca.initialize @ index-7c804f62.js:4743 Ql.initializeTerrainHeights @ index-7c804f62.js:5191 au @ index-7c804f62.js:9941 Lo @ index-7c804f62.js:15936 $i @ index-7c804f62.js:16554 _createViewer @ index-7c804f62.js:18994 $zt @ index-7c804f62.js:18994 D @ index-7c804f62.js:19029 (anonymous) @ index-7c804f62.js:19127 (anonymous) @ index-4a09dc7a.js:1 Hc @ index-4a09dc7a.js:1 El @ index-4a09dc7a.js:1 C5.e.__weh.e.__weh @ index-4a09dc7a.js:1 J3 @ index-4a09dc7a.js:1 Vse @ index-4a09dc7a.js:1 Promise.then Bse @ index-4a09dc7a.js:1 qb @ index-4a09dc7a.js:1 Yse @ index-4a09dc7a.js:1 g @ index-4a09dc7a.js:1 mL @ index-4a09dc7a.js:1 Km @ index-4a09dc7a.js:1 b5 @ index-4a09dc7a.js:1 (anonymous) @ index-4a09dc7a.js:1 mL @ index-4a09dc7a.js:1 Km @ index-4a09dc7a.js:1 b5 @ index-4a09dc7a.js:1 (anonymous) @ index-4a09dc7a.js:1 mL @ index-4a09dc7a.js:1 Km @ index-4a09dc7a.js:1 b5 @ index-4a09dc7a.js:1 set value @ index-4a09dc7a.js:1 I @ index-4a09dc7a.js:154 (anonymous) @ index-4a09dc7a.js:154 Promise.then x @ index-4a09dc7a.js:154 y @ index-4a09dc7a.js:154 u @ index-4a09dc7a.js:210 onClick @ index-4a09dc7a.js:210 Hc @ index-4a09dc7a.js:1 El @ index-4a09dc7a.js:1 n @ index-4a09dc7a.js:1 VM176:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON at JSON.parse (<anonymous>) at index-7c804f62.js:78:15443 (anonymous) @ index-7c804f62.js:78 Promise.then Dt.fetchJson @ index-7c804f62.js:78 t9 @ index-7c804f62.js:78 n9.computeXysRadians @ index-7c804f62.js:78 gi.computeFixedToIcrfMatrix @ index-7c804f62.js:78 gi.computeIcrfToFixedMatrix @ index-7c804f62.js:78 gi.computeIcrfToCentralBodyFixedMatrix @ index-7c804f62.js:78 _Me @ index-7c804f62.js:3927 hb.update @ index-7c804f62.js:3927 uTt @ index-7c804f62.js:15558 x0$5 @ index-7c804f62.js:15558 ui.render @ index-7c804f62.js:15558 Lo.render @ index-7c804f62.js:15938 i @ index-7c804f62.js:15936 requestAnimationFrame oSt @ index-7c804f62.js:15936 set @ index-7c804f62.js:15936 Lo @ index-7c804f62.js:15936 $i @ index-7c804f62.js:16554 _createViewer @ index-7c804f62.js:18994 $zt @ index-7c804f62.js:18994 D @ index-7c804f62.js:19029 (anonymous) @ index-7c804f62.js:19127 (anonymous) @ index-4a09dc7a.js:1 Hc @ index-4a09dc7a.js:1 El @ index-4a09dc7a.js:1 C5.e.__weh.e.__weh @ index-4a09dc7a.js:1 J3 @ index-4a09dc7a.js:1 Vse @ index-4a09dc7a.js:1 Promise.then Bse @ index-4a09dc7a.js:1 qb @ index-4a09dc7a.js:1 Yse @ index-4a09dc7a.js:1 g @ index-4a09dc7a.js:1 mL @ index-4a09dc7a.js:1 Km @ index-4a09dc7a.js:1 b5 @ index-4a09dc7a.js:1 (anonymous) @ index-4a09dc7a.js:1 mL @ index-4a09dc7a.js:1 Km @ index-4a09dc7a.js:1 b5 @ index-4a09dc7a.js:1 (anonymous) @ index-4a09dc7a.js:1 mL @ index-4a09dc7a.js:1 Km @ index-4a09dc7a.js:1 b5 @ index-4a09dc7a.js:1 set value @ index-4a09dc7a.js:1 I @ index-4a09dc7a.js:154 (anonymous) @ index-4a09dc7a.js:154 Promise.then x @ index-4a09dc7a.js:154 y @ index-4a09dc7a.js:154 u @ index-4a09dc7a.js:210 onClick @ index-4a09dc7a.js:210 Hc @ index-4a09dc7a.js:1 El @ index-4a09dc7a.js:1 n @ index-4a09dc7a.js:1 :60/assets/Workers/createVerticesFromHeightmap.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. :60/assets/Workers/transferTypedArrayTest.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. index-7c804f62.js:15936 WebGL渲染运行出错 (页面已停止,请刷新页面) InvalidStateError: The source image could not be decoded. InvalidStateError: The source image could not be decoded.
最新发布
10-29
我又打了一个Brotli包,报错Build6.framework.js.br:1 Uncaught SyntaxError: Invalid or unexpected token (at Build6.framework.js.br:1:2)了解此错误AI Build6.loader.js:1 Unable to parse Build/Build6.framework.js.br!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS. c @ Build6.loader.js:1 i.onload @ Build6.loader.js:1 script (匿名) @ Build6.loader.js:1 x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 Failed to parse binary data file Build/Build6.data.br (with "Content-Type: application/octet-stream"), because it is still brotli-compressed. It should have been uncompressed by the browser, but it was unable to do so since the web server provided the compressed content without specifying the HTTP Response Header "Content-Encoding: br" that would have informed the browser that decompression is needed. Please verify your web server hosting configuration to add the missing "Content-Encoding: br" HTTP Response Header. c @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 Malformed data? Downloaded binary data file Build/Build6.data.br (ArrayBuffer size: 65391783) and browser should have decompressed it, but it might have not. Dumping raw HTTP Response Headers if it might help debug: (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 accept-ranges: bytes (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 cache-control: public, max-age=31536000, immutable (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 connection: keep-alive (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 content-length: 65391783 (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 content-type: application/octet-stream (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 date: Thu, 06 Mar 2025 03:12:06 GMT (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 etag: "67c9123c-3e5cca7" (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 last-modified: Thu, 06 Mar 2025 03:10:52 GMT (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 server: nginx/1.27.1
03-08
我是windows系统,用Unity打了一个Brotli包,想放进nginx里运行,但是报错,Build6.framework.js.br:1 Uncaught SyntaxError: Invalid or unexpected token (at Build6.framework.js.br:1:2)了解此错误AI Build6.loader.js:1 Unable to parse Build/Build6.framework.js.br!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS. c @ Build6.loader.js:1 i.onload @ Build6.loader.js:1 script (匿名) @ Build6.loader.js:1 x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 Failed to parse binary data file Build/Build6.data.br (with "Content-Type: application/octet-stream"), because it is still brotli-compressed. It should have been uncompressed by the browser, but it was unable to do so since the web server provided the compressed content without specifying the HTTP Response Header "Content-Encoding: br" that would have informed the browser that decompression is needed. Please verify your web server hosting configuration to add the missing "Content-Encoding: br" HTTP Response Header. c @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 Malformed data? Downloaded binary data file Build/Build6.data.br (ArrayBuffer size: 65391783) and browser should have decompressed it, but it might have not. Dumping raw HTTP Response Headers if it might help debug: (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 accept-ranges: bytes (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 cache-control: public, max-age=31536000, immutable (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 connection: keep-alive (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 content-length: 65391783 (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 content-type: application/octet-stream (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 date: Thu, 06 Mar 2025 03:12:06 GMT (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 etag: "67c9123c-3e5cca7" (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 last-modified: Thu, 06 Mar 2025 03:10:52 GMT (匿名) @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 Promise.then x @ Build6.loader.js:1 (匿名) @ Build6.loader.js:1 createUnityInstance @ Build6.loader.js:1 (匿名) @ (索引):27了解此错误AI Build6.loader.js:1 server: nginx/1.27.1
03-08
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值