I have been trying to decode JSON from a backend system.

```
    {
        "Inst1": [
            {
                "symbol": "Inst1",
                "id": 357200929,
                "ltd": 20191220
            },
            {
                "symbol": " Inst1",
                "id": 357200932,
                "ltd": 20191220
            },
            {…}
        ],
        "Inst2": [
            {
                "symbol": "Inst2",
                "id": 357201388,
                "ltd": 20191220
            },
            {
                "symbol": "Inst2",
                "id": 371886725,
                "ltd": 20200320
            }
        ]
    }

```

The name as well as the number of top-level nodes (Inst1, Inst2) are variable and unknown. I believe the correct name for such nodes are “Dynamic Coding Keys” and that is why enum cannot be used.

The sub-nodes are in an array and always share the same structure. Their number are unknown and can be different for each top-node (e.g. inst1 may have 10 sub-nodes but Inst2 can have 5).

I’m struggling to find the correct way to decode/encode such reply. Any help would be very much appreciated. Thank you

Following Sh\_Khan answer I tried the below code but it doesn't work.

```
var json = """
{
      "Inst1": [
          {
              "symbol": "Inst1",
              "id": 357200929,
              "ltd": 20191220
          },
          {
              "symbol": " Inst1",
              "id": 357200932,
              "ltd": 20191220
          }
      ],
      "Inst2": [
          {
              "symbol": "Inst2",
              "id": 357201388,
              "ltd": 20191220
          },
          {
              "symbol": "Inst2",
              "id": 371886725,
              "ltd": 20200320
          }
      ]
  }
""".data(using: .utf8)!

struct Inst: Codable {
  let symbol: String
  let id, ltd: Int
}

let result = try? JSONDecoder().decode([String:[Inst]].self,from: json)

```