Hi! Fantastic article and nice approach! I’m giving it a try…but I have a question:
Mauro Taroco
12

Thanks Mauro!

I think the easiest way would be to tell the JSONDecoder to expect an array, something like:

let responses = try JSONDecoder().decode([MyWrapResponse.self], from: data)

However, I’m not sure that you could decode an array of generic responses, if those responses contain different information. You would have to have another wrapper to do some kind of type erasure, something like AnyResponse.

Like what you read? Give Víctor Pimentel a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.