I am retrieving a JSON from an API and I wanted to make a Model for each endpoints I use.
All the endpoints use this format:
{
"id": "xxxxxx",
"result": {…},
"error": null
}
The keys are:
id
is always a stringerror
can be null or an object with keys in itresult
can be either null; an object or an array.
The problem I am encountering is that on one of the endpoints the results are arrays of array:
{
"id": "xxxxxx",
"result": [
[
"client_id",
"name",
50,
"status"
]
],
"error": null
}
As you can see, I have arrays of array where the values can be either a String or Int.
How do you decode this using Decodable protocol and then using those decoded values as String or Int depending on their origin values?