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
Precautions:
If str is written like this at this time, as shown in the figure
Error message, as shown in the figure:
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.