[英]how to get the response JSON in swift
我收到了 Alamofire 發布請求的回復。 我想從響應中獲取狀態碼。 在代碼中:
case .success(let upload, _, _):
upload.responseJSON { response in
print(response.result.value!)
}
這是響應的樣子:
響應結果的value
屬性是一個字典。 您可以像這樣提取狀態:
let json = response.result.value as? [String: Any]
if let status = json?["status"] as? Int {
print(status)
}
struct ProfileModel: Codable {
let status: Int
let type: String
let data: ProfileDataModel
}
struct ProfileDataModel: Codable {
let ImagePath: String
let ThumbImagePath: String
}
struct ProfileModel: Codable { let status: Int let type: String let data: ProfileDataModel } struct ProfileDataModel: Codable { let ImagePath: String let ThumbImagePath: String }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.