admin管理员组文章数量:1353117
I have JSON data generated in Python using Flask's jsonify
method.
When I try to parse it in Google Chrome by doing
JSON.parse(s)
I get the error
Uncaught SyntaxError: Unexpected token N
I can't post the json since it is proprietary and gigantic. Why would I be getting this error if the JSON is generated by a well tested method?
I have JSON data generated in Python using Flask's jsonify
method.
When I try to parse it in Google Chrome by doing
JSON.parse(s)
I get the error
Uncaught SyntaxError: Unexpected token N
I can't post the json since it is proprietary and gigantic. Why would I be getting this error if the JSON is generated by a well tested method?
Share Improve this question edited Dec 4, 2013 at 18:45 codegeek 33.3k12 gold badges64 silver badges63 bronze badges asked Dec 4, 2013 at 18:22 stephenbezstephenbez 5,6583 gold badges27 silver badges31 bronze badges1 Answer
Reset to default 8Use this tool to discover the problem: https://github./zaach/jsonlint
The problem was due to Flask's jsonify allowing the serialization of NaN, but Google Chrome's implementation following the JSON spec and not allowing NaN.
Some workarounds are listed here: How to parse JSON string containing "NaN" in Node.js
本文标签: pythonJavascript JSONparse Uncaught SyntaxError Unexpected token NStack Overflow
版权声明:本文标题:python - Javascript JSON.parse: Uncaught SyntaxError: Unexpected token N - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743873659a2553931.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论