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
		},
相关推荐
鲸渔11 小时前
【AI Agent系列课程13-Python 基础13】JSON 读写:结构化数据交换基础
开发语言·python·json·ai编程
aiotto资源分享3 天前
Python 写 JSON 文件,程序中途退出会留下什么?
java·python·json·jsondecodeerror
一起学安全技术4 天前
拆大模型 10|结构化输出:让模型返回数据,而不是一段话
人工智能·语言模型·json
用户298698530144 天前
在 Python 中把 Word 文档转换为 JSON 的三种实现方式
python·json·api
FRing036 天前
vue2干货总结10(json-server、vant-ui、postcss插件、axios二次封装、图形验证码、toast轻提示)
开发语言·前端·vue.js·ui·json·vue2·postcss
用户298698530146 天前
使用 Python 将 JSON 转换为 Word 文档的实践指南
python·json·api
九英里路7 天前
protobuf快速上手
网络·c++·中间件·json·谷歌·序列化·protobuf
wuyk5557 天前
Spider-第09讲-三格式落盘CSV-Excel-JSON
爬虫·python·json·excel
wuyk5558 天前
Spider-第07讲-JSON接口与正则提取
爬虫·python·json
xbzb11 天前
镜像到底存在哪:/var/lib/docker 的四级映射与 daemon.json 配置
docker·容器·json·镜像·daemon.json·四级