unaipp通过JSON.stringify传值页面JSON.parse转换报错

因为JSON.stringify 后的字符串通过 URL 传递时,特殊字符(如 /=& 等)会被自动转义(比如 %22 代表双引号),如果直接 JSON.parse 会因字符不匹配报错,必须先解码。

https://www.xxxx.com/Gateway/InterfaceV?InstitutionIDxxxx

传递页面

复制代码
let BankRedirctFormH5 = {
							imp: "https://www.chinaxxx.com/Gateway/InterfaceV?InstitutionID=008824&Txxxxx"
						}
						uni.navigateTo({
							url:'/subpackageAnew/myCard/BankRedirctFormH5?impOBJ=' + JSON.stringify(BankRedirctFormH5)
						})

接受页面

复制代码
onLoad(options) {
			// 先解码(对应跳转前的 encodeURIComponent)
			const decodeStr = decodeURIComponent(options.impOBJ);
			// 再解析 JSON
			this.impOBJ = JSON.parse(decodeStr);
			console.log("解析成功:", this.impOBJ);
			// this.imp = op.imp
		},
相关推荐
上海合宙LuatOS7 天前
LuatOS核心库API——【json 】json 生成和解析库
java·前端·网络·单片机·嵌入式硬件·物联网·json
敲代码的柯基7 天前
一篇文章理解tsconfig.json和vue.config.js
javascript·vue.js·json
万物得其道者成7 天前
前端大整数精度丢失:一次踩坑后的实战解决方案(`json-bigint`)
前端·json
Ai runner8 天前
Show call stack in perfetto from json input
java·前端·json
ID_180079054738 天前
淘宝商品详情API请求的全场景,带json数据参考
服务器·数据库·json
恒云客8 天前
python uv debug launch.json
数据库·python·json
wanderist.9 天前
从 TCP 到 JSON:一次 FastAPI + LLM 生产环境 “Unexpected end of JSON input” 的底层剖析
tcp/ip·json·fastapi
享誉霸王9 天前
15、告别混乱!Vue3复杂项目的规范搭建与基础库封装实战
前端·javascript·vue.js·前端框架·json·firefox·html5
今心上10 天前
关于json的理解测试!!
开发语言·json
强子感冒了11 天前
JSON和XML学习笔记
xml·学习·json