Add raw JSON preservation capability to v3 API results for accessing undefined fields #3659
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
微信支付v3 API经常会返回新的字段,但这些字段可能还没有在WxJava的Result类中定义。例如,微信支付批次详情接口返回的
card_id
字段在FavorStocksGetResult
类中就没有定义。当官方API更新时,开发者无法访问这些新增字段,只能等待框架更新。Solution
添加了原始JSON内容保存功能,允许开发者访问API返回的任何字段,即使这些字段未在Result类中定义。
核心实现
新增BaseWxPayV3Result基类
rawJsonString
字段保存原始API响应xmlString
的设计模式更新Result类继承结构
FavorStocksGetResult
- 查询批次详情FavorStocksCreateResult
- 创建代金券批次FavorCouponsGetResult
- 查询代金券详情修改服务实现
GSON.fromJson()
后调用setRawJsonString()
保存原始内容使用示例
特性
测试覆盖
Fixes #3565.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.