gpt4 book ai didi

java - 尽管采用 json 编码,但所需参数不存在

转载 作者:行者123 更新时间:2023-11-30 11:37:32 25 4
gpt4 key购买 nike

我正在使用 alamofire 从 swift 发送 http post 请求:

let url = userActivity.webpageURL

if(url?.description.contains(UniversalLinkHandler().urlPrefix))!
{
let keystore = try! EtherKeystore()
let signedOrder = UniversalLinkHandler().parseURL(url: (url?.description)!)
let signature = signedOrder.signature.substring(from: 2)
let parameters: Parameters = [
"address" : keystore.recentlyUsedWallet?.address.description,
"indices": signedOrder.order.indices,
"v" : signature.substring(from: 128),
"r": signature.substring(from: 0, to: 64),
"s": signature.substring(from: 64, to: 128)
]
let query = UniversalLinkHandler.paymentServer

Alamofire.request(
query,
method: .post,
parameters: parameters
).responseJSON {
result in
print(result)
}
}

索引在调试器中显示为普通的 UInt16 数组,但是当发送到服务器时,它表示索引数组不存在

服务器是java语言,使用springboot:

@RequestMapping(value = "/claimToken", method = RequestMethod.POST)
public ResponseEntity getAToken(@RequestParam(value="address") String address,
@RequestParam(value="indices") int[] indices,
@RequestParam(value = "v") byte v,
@RequestParam(value = "r") String r,
@RequestParam(value = "s") String s
)

第一个参数地址工作得很好,但它不适用于 int[] 索引数组

非常感谢任何帮助。

最佳答案

由于您的 signedOrder.order.indices 数组导致了您的问题,并且其类型为 [UInt16],因此我的建议是:

let indices = signedOrder.order.indices.map(Int.init)
let parameters: Parameters = [
"address" : keystore.recentlyUsedWallet?.address.description,
"indices": indices,
"v" : signature.substring(from: 128),
"r": signature.substring(from: 0, to: 64),
"s": signature.substring(from: 64, to: 128)
]

映射到 Int 可能会很好地解决您的问题。

关于java - 尽管采用 json 编码,但所需参数不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49585722/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com