I need a way to decode JSON into Swift structure, but start decoding not from top level of JSON.
For example, I have some JSON response like this
{"response": { "name": "John", "id": 2"} }
Actually, I need only need the nested object with name and id fields, I do not need top level "response" in my struct.
So the question is:
Can I decode that nested object without "response" top level?
But it would be good, if I can check, if this top level "response" exists, and then decode.
My API returns either top level "response" with response object inside or top level "error" with error object inside, so I have to check if there is error or response before decoding.