解析 JsonArray 响应数据

Parse JsonArray response data

我有一个这样的 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"
    }
]

我使用 alamofire 5.2 来获得响应。我如何解析此数据以获取所有值?

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]](字典数组)