VM356:1 Uncaught SyntaxError: Unexpected token i in JSON at position 1
来源:互联网 发布:c语言基础代码大全 编辑:程序博客网 时间:2024/05/24 01:50
本人在用JSON.parse把字符串转化为json对象时,一直报错VM356:1 Uncaught SyntaxError: Unexpected token i in JSON at position 1,很费解,var str1 = "{'name':'cxh','sex':' man'}";一直认为这个字符串没有任何问题,最终发现,使用parse这个方法,要求很严格,必须是var str1 = '{ "name":"cxh","sex":" man" }';就是json的k和value必须都用双引号包起来;
谨记json格式问题k和value都加双引号,单引号也不可以
var str1 = '{ "name":"cxh","sex":" man" }';
console.log(JSON.parse(str1));
console.log(JSON.parse(str1)["name"]);
阅读全文
0 0
- VM356:1 Uncaught SyntaxError: Unexpected token i in JSON at position 1
- VM356:1 Uncaught SyntaxError: Unexpected token i in JSON at position 1
- Uncaught SyntaxError: Unexpected token o in JSON at position 1
- Uncaught SyntaxError: Unexpected token o in JSON at position 1
- Uncaught SyntaxError: Unexpected token o in JSON at position 1
- Uncaught (in promise) SyntaxError: Unexpected token o in JSON at position 1
- 【已解决】Uncaught SyntaxError: Unexpected token o in JSON at position 1
- Javaweb中 Uncaught SyntaxError: Unexpected token o in JSON at position 1
- 代码中出现:Uncaught SyntaxError: Unexpected token o in JSON at position 1
- Uncaught SyntaxError: Unexpected token < in JSON at position 0
- 解决方法 Uncaught SyntaxError: Unexpected token < in JSON at position 0
- Uncaught SyntaxError: Unexpected token ] in JSON at position 问题
- SyntaxError: Unexpected token s in JSON at position 1
- 关于Uncaught SyntaxError- Unexpected token o in JSON at position 1,chrome持续报错的相关解析
- Atitit Uncaught (in promise) SyntaxError Unexpected token < in JSON at position 0
- primefaces 推送服务报Uncaught SyntaxError: Unexpected token < in JSON at position 0
- 【已解决】Uncaught SyntaxError: Unexpected token in JSON at position 0
- SyntaxError: Unexpected token s in JSON at position 111518
- MySQL数据库数据增删改查语言和使用例子
- 算法概论习题8.14
- python 小工具总结
- Servlet学习
- 钉钉自定义机器人
- VM356:1 Uncaught SyntaxError: Unexpected token i in JSON at position 1
- thymleaf标签使用
- Linux下的sed、awk、cut、sort、uniq工具
- Nutz
- RxJava之基础入门
- 用户管理
- 纪念一下自己成为了权限狗
- Luogu 1894 [USACO4.2]完美的牛栏The Perfect Stall
- 解析ANDROID ps命令执行后各项参数的含义