Select Page

One of the kind of neat, newer features in Swift is that you can create classes that are Codable. In the app, I get some JSON from the server. Here’s the abridged JSON:

You can create Swift structs that mirror the JSON and then decode (with data type validations/translations) easily. Here’s the corresponding Swift struct

Then the code to convert the JSON into structs is simply: .

And then later

Share This