when decoding JSON from webservice(API) i get error :
Could not cast value of type \'__NSDictionaryM\' (0x1037ad8a8) to \'NSArray\' (0x1037ad470). >
Could not cast value of type \'__NSDictionaryM\' (0x1037ad8a8) to \'NSArray\' (0x1037ad470).
try cache for Serialization
do { if let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String : Any] { // as? data type if let otherDict = json["dataKey"] as? [String : Any] { //do something } } } catch { // can't json serialization }