kiran
kiran

Reputation: 4409

Why response Structure Change from : to =

Service Call using pod 'Alamofire', '~> 4.8.2' that is maximum for Xcode 10.1 is supported, due to hardware comparability

MacBook Pro (13-inch, Early 2011) Mac High Sierra

Below is Request function for login Services Call.

func loginRequest (urlString: String){

    let parameters = [
        "email": "[email protected]",
        "password": "YourPassword"
    ]

        Alamofire.request(urlString, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: nil).responseJSON { (response) in

            switch response.result {
            case .success(let JSON):
                print("\n\n Success value and JSON: \(JSON)")

            case .failure(let error):
                print("\n\n Request failed with error: \(error)")

            }
        }
}

Response Data

{
    data =     {
        stauts =         {
            fullname = "yourname";
            email = "[email protected]";
            gender = "";
            notificationCount = 2;
           token = "SomeTokenString";

        };

}

Expected the response data in JSON Formate. But its was not.

No idea why the response structure changed from : to =

Upvotes: 0

Views: 42

Answers (1)

vadian
vadian

Reputation: 285082

If you specify the responseJSON parameter the data is returned deserialized, in your case as a [String:Any] dictionary.

To get the raw data replace responseJSON with responseData

Upvotes: 3

Related Questions