) at :1:6 str = '{&quo"> Things to note when converting string to json-JS Tutorial-php.cn

Things to note when converting string to json

一个新手
Release: 2017-10-09 10:06:21
Original
1546 people have browsed it

I have been working on a post for a day, sometimes it is normal and sometimes it is wrong!

let str = "{'name':'wanglei'}"; let obj = JSON.parse(str);
Copy after login

The above will report an error:

VM143:1 Uncaught SyntaxError: Unexpected token ' in JSON at position 1 at JSON.parse () at :1:6 str = '{"name":"wanglei"}';
Copy after login

That’s it!

key and value must be in double quotes and comply with json specifications

The above is the detailed content of Things to note when converting string to json. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!