I have an json array respone like this;
[
{
"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"
}
]
I use alomifere 5.2 to get response. How can I parse this data to get all values?
CodePudding user response:
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
}
}
Change successResponse as! [[string:Any]] (array of dictionary)