last day (15 days later) » 

7:43 PM
0
A: Swift : The data couldn’t be read because it isn’t in the correct format

Robert DreslerYour value for _source key is single object, not an array. var _source: _source Anyway, I would change names of your properties and model to some more Swifty names and I would also use struct instead of class struct Album: Decodable { var source: Source enum CodingKeys: String, Codi...

 
@LeoDabus he doesn't have it in his model, so... why should I add it?
 
why you used Decodable? Instead of Codable ?
 
@KrunalNagvadia if you just need to decode your response, you need just Decodable protocol. Encodable is useful if you need to encode your model to Data. Codable is just typealias for these two protocols
 
but showing me Type 'Album' does not conform to protocol 'Decodable' error
 
@KrunalNagvadia what? Have you used my code as I wrote it? Because I don't have this error
 
7:43 PM
yes. it's still showing me same error. (Incorrect Format)
 
@KrunalNagvadia please post your exact error message
 
The data couldn’t be read because it isn’t in the correct format.
 
Yes, but the full error message
 
Sorry not getting. This is what I get the error. I have no idea how to get the full error details
 
Instead of print(error.localizedDescription) use print(error)
in do try catch block
what do you see then?
 
7:49 PM
typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
 
And have you use just single object for Source instead of [Source]?
You need Source
also, what is your full json?
I mean full json
maybe it isn't just an array of Albums
 
yes i used single Source
 

last day (15 days later) »