Type 'Any' doesn't conform to protocol 'Sequence'
10,123
Specify the type of jsonDataArray to directly [[String: Any]]
and try like this.
if let jsonDataArray = try? JSONSerialization.jsonObject(with: data!, options: []) as? [[String: Any]] {
for eachData in jsonDataArray {
let eachStop = busStops(jsonDataDictiony: jsonDataDictionary)
}
}
Author by
Ronald Aja
Updated on June 05, 2022Comments
-
Ronald Aja almost 2 years
I am having troubles in my codes, when trying to parse JSON data (each data of an array, like how it should be done) and trying to set up the for in loop, the error comes out. Here's my code
if let jsonDataArray = try? JSONSerialization.jsonObject(with: data!, options: []) { print(jsonDataArray) var allStops = [busStops]() for eachData in jsonDataArray ^ //this is where the error is located { if let jsonDataDictionary = eachData as? [String : AnyObject] { let eachStop = busStops(jsonDataDictiony: jsonDataDictionary) } } }
-
Rajasekhar Pasupuleti about 6 yearsThanks, It is worked for me. if let corners = barcodeMetadataObject.corners as? [[String: Any]] { }