0

I have the following simple JSON:

{
    "201" :
    {
        "countryName" : "Albania",
        "countryCode" : "AL"
    },
    "202" :
    {
        "countryName" : "Andorra",
        "countryCode" : "AD"
    },
    ...
}

The inner dictionary simply becomes:

struct Mid : Codable
{
    var countryName: String
    var countryCode: String
}

But then I'm stuck. How do I represent the outer dictionary?

I want to end up with a dictionary of Mid objects with String keys "201", "202", ...

meaning-matters
  • 21,929
  • 10
  • 82
  • 142

1 Answers1

3
  • Simple solution:

    • Decode [String:Mid]
  • Sophisticated solution if you want an array:

vadian
  • 274,689
  • 30
  • 353
  • 361