I have the following piece of code available here that decodes a JSON response from the Kitsu API (seriously just copy and paste in a playground environment and you should be good to go).
I am running into some decoding error that makes the code in the try statement fail and I have no idea why.
I have two links that return the same JSON body (different results but same structure) except one fails and one doesn't.
// "https://kitsu.io/api/edge/anime?sort=popularityRank" <-- works
// "https://kitsu.io/api/edge/anime?sort=-startDate" <-- does not work
To help debug the one that fails I print out data with the following statement:
print(String(data: data!, encoding: String.Encoding.utf8) as Any) // "as Any" to suppress warnings
And with this I am able to see the data object contains everything I need, so I'm ruling out a bad response (text was too large to copy so here's a screenshot, you'll get the picture):
If I had to guess, the issue is in the parsing, but the way I'm parsing it works for the first link. What exactly can I do to debug this? I've compared the json side by side and like I said, the structure between the responses is the same, only the content differs.
