我有一個這樣的 json 陣列回應;
[
{
"id": 62,
"type_id": 1,
"coordinate": {
"x": 2273.73828125,
"y": 1568.015625000001
},
"name": "x"
},
{
"id": 57,
"type_id": 1,
"coordinate": {
"x": 1405,
"y": 343.99999999999704
},
"name": "y"
}
]
我使用 alomifere 5.2 來獲得回應。如何決議此資料以獲取所有值?
uj5u.com熱心網友回復:
Alamofire.request("YOUR_URL", method:.post, parameters:params, encoding:URLEncoding.default, headers: nil).responseJSON { response in
switch(response.result)
{
case .success(_):
if response.result.value != nil
{
let arr :[[String:Any]] = response.result.value! as! [[String:Any]]
print(arr)
}
break
case .failure(_):
print(response.result.error)
break
}
}
將成功回應更改為![[string:Any]](字典陣列)
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/377185.html
