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
		},
相关推荐
2601_962066936 小时前
短视频批量制作怎么做?2026年用 huasheng-cli 的 --json 与退出码,一张选题表批量出片
json·音视频
oliver_sys_log1 天前
老项目 json-lib 2.4 JSONTokener 精度丢失问题排查
json
IT_Octopus1 天前
JSON 日志里的 `{“$ref“:“$.xxx“}`:从 fastjson 兼容包到原生 fastjson2 的迁移实录
开发语言·python·json
数据狐(Datafox)2 天前
mercadolibre.item_get 工程实战:美客多商品详情API技术解析与落地应用
java·人工智能·mysql·json
Fcy6482 天前
Linux下 应⽤层⾃定义协议与序列化(JSON方法)
linux·json
半亩码田3 天前
C#转Python第4.4篇:JSON 处理:json 模块 vs System.Text.Json
python·c#·json
清水白石0083 天前
Python 类型设计深度解析:TypedDict 能否替代 dataclass?从 JSON 数据边界到 API 设计的最佳实践
java·python·json
DevOpenClub3 天前
网页采集如何稳定输出结构化数据:JSON、链接与快照三阶段流水线
数据库·json·api
霸道流氓气质4 天前
Spring AI 结构化输出:JSON Mode 与 BeanOutputConverter
人工智能·spring·json
SelectDB5 天前
StarRocks 适合做日志分析吗?
数据分析·json·自动化运维