VM356:1 Uncaught SyntaxError: Unexpected token i in JSON at position 1
2017-07-04 17:15
639 查看
本人在用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"]);
谨记json格式问题k和value都加双引号,单引号也不可以
var str1 = '{ "name":"cxh","sex":" man" }';
console.log(JSON.parse(str1));
console.log(JSON.parse(str1)["name"]);
相关文章推荐
- VM356:1 Uncaught SyntaxError: Unexpected token i in JSON at position 1
- js获取富文本编辑器的值之后报错Uncaught 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
- 关于Uncaught SyntaxError- Unexpected token o in JSON at position 1,chrome持续报错的相关解析
- 【已解决】Uncaught 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 < in JSON at position 0
- 代码中出现:Uncaught SyntaxError: Unexpected token o in JSON at position 1
- Uncaught (in promise) SyntaxError: Unexpected token o in JSON at position 1
- SyntaxError: Unexpected token s in JSON at position 111518
- Uncaught SyntaxError: Unexpected token o in JSON at position 1
- Uncaught SyntaxError: Unexpected token < in JSON at position 0
- Uncaught SyntaxError: Unexpected token o in JSON at position 1
- angular1.5.3.min.js:116 SyntaxError: Unexpected token g in JSON at position 63
- Ajax报错之Unexpected token S in JSON at position
- js常见报错之Unexpected token in JSON at position
- Http status: 200 OK ajaxOptions: parsererror thrownError: SyntaxError: Unexpected token < in JSON at
- Unexpected token u in JSON at position 0 的解决过程