Hey there, I'm trying to decode an json with an dynamic dict as value.
eg.
"results": [
{
"id": 1799,
"created_at": "2024-05-09T14:21:13.289655Z",
"updated_at": "2024-05-10T11:54:25.484537Z",
"email": "test@test.testh",
"name": "Test",
"attributes": {
"name": {
"firstname": "max",
"lastname": "mustermann"
},
"anboolen": false,
"anNumber": 1,
"anString": "Test"
}
}
]
The dictionary "attributes" is always an dictionary but the content inside could be everything.
for the container of results I already created an struct and using JSONDecoder to decode, but now I have the issue with the attributes part.
Can anyone help me with this issue?
Thanks in advance!
The dictionary "attributes" is always an dictionary but the content inside could be everything.
Be more explicit. Is it [String: Any] ?
Please show how you have defined the struct that will hold the decoded JSON.
How is attributes defined there ?
You may find interesting info here: https://stackoverflow.com/questions/44603248/how-to-decode-a-property-with-type-of-json-dictionary-in-swift-45-decodable-pr