【微信小程序】微信小程序页面url传参,使用JSON.parse报错Unexpected end of JSON input

微信小程序页面url传参,使用JSON.parse报错Unexpected end of JSON input

参考

一开始以为是url传参的长度限制原因。

其实是因为参数中有特殊字符导致数据截取,所以接收参数后,无法解析json格式。

用的解决方法是encodeURIComponent()和decodeURIComponent(),见参考文章。