I am using Alamofire for networking request. It works fine except one issue.
manager!.request(mutableURLRequest).responseJSON { (response) in
switch response.result {
case .Success:
if let value = response.result.value {
print("JSON: \(value)") //**problem**
}
case .Failure(let error):
print(error)
}
}
The server response format is :
"result" : [
{
"rec_name" : "1.jpg",
"data": {
"base64": "/9j/4AAQSkZ",
"__class__": "bytes"
},
"id" : 9,
"name" : "1.jpg"
},
{
"rec_name" : "2.jpg",
"data": {
"base64": "/9j/4AAQSkZ",
"__class__": "bytes"
},
"id" : 10,
"name" : "2.jpg"
}
],
"id" : 0
}
But I am getting as follow: data(base64 String) is null
"result" : [
{
"rec_name" : "1.jpg",
"data" : null,
"id" : 9,
"name" : "1.jpg"
},
{
"rec_name" : "2.jpg",
"data" : null,
"id" : 10,
"name" : "2.jpg"
}
],
"id" : 0
}
Did I miss something for base64 string? I think it is working before a month but now I am getting issue.
If I make same request via POSTMAN then it works fine!
Thank you,
I can advice you library SwiftyJSON. This library allows you to parse JSON in Swift easily. Also, there is extension AlamofireSwiftyJSON that unites Alamofire and SwiftyJSON. Here is an example for your request: