JSON.Parse JS step on the recording pit () conversion failed

EDITORIAL words:

When reading the data to the database configuration after the front end in the form of a string of json, front-end JSON.parse () method converts the string of tips failed to sum up the way it resolved:

1. string escape

2. Save time data is encoded

3. The rear end of the object returned directly using the JSON.parse Skip () method

1. string escape

Some common escape characters:

1, Space: & nbsp; 

2、& :& 

3、<  :&lt;

4、>  :&gtl;

5、"   :&quot;

6、'    :&apos;

6. Copyright: & copy;

2. Save time data is encoded

 

 After the file is coded errors that may appear before saving using js own encodeURI () it requires time to read () method and then decode the string with decodeURI.

3. The rear end of the object returned directly using the JSON.parse Skip () method

If the data is passed over from the rear end, you can replace the JSON string object also skip mode using the JSON.parse () method.

 

Guess you like

Origin www.cnblogs.com/lin494910940/p/12454842.html