I am trying to extract the value from a JSON serialization but getting nil as the result.
App was working under Swift2 so its the conversion to Swift 3 where the issue started.
let jsonResult = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
print(jsonResult!)
let mySuccess = jsonResult?["success"] as? Int
print (mySuccess!)
The print(jsonResult!) gives the following output
{
"full_login" = 0;
"logged_in" = 1;
message = "<null>";
success = 1;
}
So all good so far and my parsing is working and I now have the data from the server.
However print(mySuccess!) gives this output
fatal error: unexpectedly found nil while unwrapping an Optional value
So I understand the output saying that the code found nil while unwrapping, so my issue now is how do I extract the value of the "Success" key as it was behaving under Swift 2 but now not so under Swift 3?
UPDATE
Sneak found a possible issue that success = 1 do not have the "" so will update question answer once I investigate.