JSON string parameter passing applet of (special characters)

    

Applet page jump pass an array of objects to use JSON.stringify () and JSON.parse ();

 JSON.stringify () method is a JavaScript value (object or array) is converted to a string JSON

JSON.parse ()  method to convert the data to a JavaScript object (character string will be transferred into json objects.)

Transfer page: JSON.stringify by the method, an array or a string object into passed

1482762-591e72614587fd7c.png

Received page: the string into the object, and then use 

1482762-adc543d7fc178c87.png

But today face a special situation:

The results JSON.stringify (this.data.totalFuntions) is a correct and complete json string, but the receiving page JSON.parse (options.title) is indeed get a json incomplete data, the reason is because JSON.stringify ( this.data.totalFuntions) which contains the & this character, is intercepted during transmission, the receiving interface only in the front part of it to give


1482762-71264ee62ab95afb.png

Was conducted in getting the data logic, I am by dividing pageUrl.split ( "?") [0], reserved? Before a string of parameters can be self splicing question mark next interface. (Tips: .replace replacement string ( '/ & / g', '') does not work, I nail applet).


1482762-2c46d90b554c20ce.png

This OK.

Because more details on the time spent, for everyone to share. I wish you can go on the road to smooth some of the applet.

Reproduced in: https: //www.jianshu.com/p/2d23d3189fd4

Guess you like

Origin blog.csdn.net/weixin_34293911/article/details/91296056