|
I am loading a JSON from a URL. The loading appears to work, but Decoding fails with this message:
I am running out of ideas and a little help would be welcome. Thanks... Here is my code:
|
|
It's because your JSON contains invalid characters. In this particular case, it contains a linebreak character. And not just a linebreak, an HTML linebreak tag! You can see it when I dump the raw JSON returned from your API call: You will need to clean up your JSON before you can decode it because there are several of these. Looks like there's also
Put something like this in after you get the
And make sure you use |
|
@rooster! nice find! What tool did you use to dump the raw JSON? I used You picked a better tool! |
|
I just dumped the raw data in a playground using this:
But I also checked it out in RapidAPI (formerly known as Paw), which is how I found the info about the
Because, I assume, you plugged the API URL into a browser and then copied the resulting JSON out of the browser window and into the JSONFormatter text box. The browser wouldn't show you the That's also why |
|
Thanks @roosterboy ! I had copied and pasted the json from my browser into various validating sites and created a file which decoded fine! Of course, my browser had already suppressed all that html junk ;-) |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's all new Paywall Editor allow you to remotely configure your paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.