I am having issue to grab value from JSON in swift 4.
{
"meta": {"expiration": 0,"flags": 33456},
"json": "{\"key\":\"string\",\"value\":{\"failed_attempts\":\"1\"}}",
"xattrs": {}
}
The code I have tried
if let resultData = responseBody["json"] as? [String: AnyObject]{
if let val = resultData["value"] as? [String: AnyObject]{
if let attempt = val["failed_attempt"] as? String {
print(attempt)
}
}
}
I have tried to print below line, it correctly prints all object inside json array but when ever i tried to add a return type as [String: AnyObject] it returns nil value. Could someone please give me some advise.
response["json"]