根据Json数据,如果json data (success = true)
,那么我只想将用户移动到下一个View Controller。
{
"success": true,
"message": "Loged In",
"User_details": {
"user_id": "208",
"user_name": "Samad",
"phone": "9705994458",
"email": "laddafsamad.12@gmail.com",
"image": "https://laex.in/testprep/Dashboard/uploads/user/1499063695.jpg"
}
}
答案 0 :(得分:0)
if let responce = yourJson as? [String: Any],
let isSuccess = responce["success"] as? Bool,
isSuccess {
// Send user to next viewcontroller
}
试试这段代码:)
答案 1 :(得分:0)
let result : NSDictionary! = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! NSDictionary
if let success = result.value(forKey: "success") as? Bool {
if success {
// navigate to next viewcontroller
}
}