Top "Codable" questions

Use this tag only for questions directly pertaining to the Swift Codable protocol introduced in Swift 4.

Protocol type cannot conform to protocol because only concrete types can conform to protocols

Within the app, we have two types of Stickers, String and Bitmap. Each sticker pack could contain both types. This …

ios swift protocols codable decodable
How to use swift 4 Codable in Core Data?

Codable seems a very exciting feature. But I wonder how we can use it in Core Data? In particular, is …

swift core-data swift4 xcode9 codable
How to use Any in Codable Type

I'm currently working with Codable types in my project and facing an issue. struct Person: Codable { var id: Any } id …

ios swift codable decodable encodable
Expected to decode Array<Any> but found a dictionary instead

I was fetching data from an API returning an array but needed to replace it by an API that has "…

swift api codable
Swift Codable null handling

I have a struct that parse JSON using Codable. struct Student: Codable { let name: String? let amount: Double? let adress: …

ios json swift codable decodable
Swift 4 JSON Decodable simplest way to decode type change

With Swift 4's Codable protocol there's a great level of under the hood date and data conversion strategies. Given the …

json swift swift4 codable
Swift 4 Decodable: The given data was not valid JSON

I'm trying to write a POST request to my local server, this is my function: @IBAction func postButtonAction(_ sender: UIButton) { …

ios json swift codable decodable
Swift 4 Codable; How to decode object with single root-level key

I'm using the Swift 4 Codable protocol with JSON data. My data is formatted such that there is a single key …

json swift deserialization swift4 codable
Swift 4 Codable Array's

So I have an API route that returns a JSON array of objects. For example: [ {"firstname": "Tom", "lastname": "Smith", "age": 31}, {"…

swift swift4 codable
Using codable with value that is sometimes an Int and other times a String

I have an API that will sometimes return a specific key value (in this case id) in the JSON as …

json swift swift4 codable