I need to check a json response and find out if the response has a key.
I found other similar questions but they are working with libraries like SwiftyJSON.
I don't want to use that.
I need to know if its possible to do this without using any third party libs?
My current code is this:
let data = str.data(using: .utf8)!
do {
if let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? NSDictionary
{
print(jsonArray)
// I NEED TO DO CHECKS HERE...
// something like this:
if (jsonArray['someKey'] = exist){
do something here
}else{
do something else
}
}
}
Is this possible at all?