Home  >  Article  >  Web Front-end  >  JSON.parse 解析字符串出错的解决方法_javascript技巧

JSON.parse 解析字符串出错的解决方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:23:371424browse
JSON.parse 解析字符串出错的解决方法_javascript技巧
经查,原来是json数据的格式要求非常严格,属性名称必须是用双引号“”括起来。

复制代码 代码如下:

var a=JSON.parse('{"a":"aaaaa"}');//正确
var a=JSON.parse("{'a':'aaaaa'}");//错误
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn