Monday, 29 July 2019

Alamofire in iOS is Receiving Dictionary Instead of Array

I am working on creating tables in iOS and am supposed to be receiving the required data in the form of JSON arrays. However, when I get the data in my iOS app it is presented as an unsorted dictionary instead. I was able to run the GET request in Postman and receive the data correctly, but when I receive it through Alamofire in my iOS app it is not formatted correctly. Is it possible that Alamofire would reformat the JSON somehow and convert all arrays to dictionaries, and can I override that setting somehow?

Here is an example of the column section of the JSON in Postman:

enter image description here

And here is what I am receiving through Alamofire:

enter image description here

This is how I am attempting to access the JSON

if let jsonColumns = json["columns"] as? [[String:Any]] {
        for columns in jsonColumns {
            for column in columns.values {
                if let c = column as? [String:Any] {
                    if c["isVisible"] as? Bool == false {
                        continue
                    }
                    if let columnName = c["name"] as? String {
                        dataSet.columns.append(columnName)
                    }
                }
            }
        }
    }



from Alamofire in iOS is Receiving Dictionary Instead of Array

No comments:

Post a Comment