我想获得redirectUrl价值。所以我写这样的代码。我觉得太复杂了。可能有其他方法可以得到吗?var v interface{}req.ToJSON(&v)a := v.(map[string]interface{})b := a["browserPayment"].(map[string]interface{})logs.Info(b["redirectUrl"])这是回应:{"browserPayment":{"interaction":{"status":"INITIATED","timeInitiated":"xxxxxx"},"operation":"PAY","redirectUrl":"xxxxx","returnUrl":"http://localhost"},"gatewayEntryPoint":"xxxxx","merchant":"xxxxx","order":{"amount":1,"chargeback":{"amount":0,"currency":"USD"},"creationTime":"xxxxxx","currency":"USD","id":"xxxxxx","merchantAmount":1,"merchantCurrency":"USD","status":"INITIATED","totalAuthorizedAmount":0,"totalCapturedAmount":0,"totalRefundedAmount":0},"response":{"gatewayCode":"SUBMITTED"},"result":"SUCCESS","sourceOfFunds":{"type":"UNION_PAY"},"timeOfRecord":"xxxxxxx","transaction":{"acquirer":{"id":"xxxxxxx","merchantId":"xxxxx"},"amount":1,"currency":"USD","id":"xxxxx","source":"INTERNET","type":"PAYMENT"},"version":"56"}
1 回答
鸿蒙传说
TA贡献1865条经验 获得超7个赞
声明一个类型与数据结构匹配的变量。解组该值:
var v struct { BrowserPayment struct { RedirectUrl string }}
req.ToJSON(&v)
logs.Info(v.BrowserPayment.RedirectUrl)
建议:检查并处理ToJSON返回的错误。
- 1 回答
- 0 关注
- 117 浏览
添加回答
举报
0/150
提交
取消