Jquery's parseJSON conversion error displays "invalidJSON" solution

Debugging a piece of JSON today, the data contains a lot of html tags, and some other messy things.

I use version 1.44 of JQuery. After working for a long time, I keep reporting the error "invalid json", which makes it impossible to convert

Because there are too many tags in the data, first clear the html tags in the background, and then HtmlEncode transcoding, the result is still wrong!



Finally, it was found that the line break in the data was converted to "\r\n" due to HtmlEncode, and "\" was used as an escape character, knowing that json was truncated. . .



Of course, this is only a cause of error, and the attribute and data must be double quoted. Since the data I am dealing with is in English, single quotes will appear from time to time, which will also cause truncation of the JSON format.


Guess you like

Origin blog.csdn.net/bsxfbs/article/details/8545245