How to convert json string into json object

In the process of data interaction, json is transmitted in the form of text, and js operates on json objects, so we need to convert strings that conform to json format into json objects for operation .

One: There are two ways to convert a json string into a json object

    bb.jpg

Precautions:

    If str is written like this at this time, as shown in the figure

cc.jpg

Error message, as shown in the figure:

dd.jpg

So, to summarize:

It must be written as: single quotes on the outside, double quotes for the properties inside. Otherwise an exception will be thrown.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324646825&siteId=291194637