0

I'm in a situation where the response JSON is of kind [String: Any], something like below:

{ "response": {"a": 1, "b": "String", "c": [] }}

Now at the client side, we don't know the keys for the response, we need to consume the response as it is and forward the dictionary received as a response to another api. Hence, the requirement is to store the response as [String: Any]. With the code below to parse the response,

try values.decode([String: Any].self, forKey: "response")

I get an error

No 'decode' candidates produce the expected contextual result type '[String : Any]'.

Please suggest on how I can parse it as [String: Any].

Thank you

Shashank
  • 1,743
  • 1
  • 14
  • 20

0 Answers0