About 52 results
Open links in new tab
  1. ios - How to directly convert a Dictionary to a Codable instance in ...

    Jul 1, 2021 · But it doesn't sound like you actually need any codable thing to be initializable from a Dictionary, just your model. In that case, rather than extend Decodable, just extend your model.

  2. swift - When to use CodingKeys in Decodable - Stack Overflow

    Nov 2, 2021 · First of all there is a make-or-break rule for using CodingKeys: You can omit CodingKeys completely if the JSON – or whatever Codable conforming format – keys match exactly the …

  3. How do I use custom keys with Swift 4's Decodable protocol?

    Swift 4 introduced support for native JSON encoding and decoding via the Decodable protocol. How do I use custom keys for this? E.g., say I have a struct struct Address:Codable { var street:S...

  4. ios - How to use Any in Codable Type - Stack Overflow

    Codable needs to know the type to cast to. Firstly I would try to address the issue of not knowing the type, see if you can fix that and make it simpler. Otherwise the only way I can think of solving your …

  5. How can I use Swift’s Codable to encode into a dictionary?

    Jul 20, 2017 · 3 I definitely think that there's some value in just being able to use Codable to encode to/from dictionaries, without the intention of ever hitting JSON/Plists/whatever.

  6. swift - When to use decodable, Codable, and encodable to retrieve …

    Nov 14, 2021 · Codable means that the entity is both Encodable (ie can be encoded into data) and Decodable (can be decoded from data). When getting data from an API, you need Decodable data. …

  7. swift - Codable [String: Any] dictionary - Stack Overflow

    Think about what it means to conform to Codable. Conforming to Codable implies that your class can be converted to and from JSON. How do you convert a [String: Any] into a JSON format? Or in other …

  8. Swift Rest API call example using Codable - Stack Overflow

    Jan 24, 2021 · Swift Rest API call example using Codable Asked 5 years, 1 month ago Modified 2 years, 11 months ago Viewed 5k times

  9. Swift Encodable, Decodable Vs Codable - Stack Overflow

    Mar 12, 2020 · Found in Apple doc, that Codable protocol is composed of Encodable and Decodable. Thus, Codable = Encodable & Decodable Now, let's say I implemented below classes, class X: …

  10. json - Using codable with value that is sometimes an Int and other ...

    Dec 22, 2017 · I have an API that will sometimes return a specific key value (in this case id) in the JSON as an Int and other times it will return that same key value as a String. How do I use codable to parse …