|
(i have the below code for decoding JSON data, but i am not getting th response. Instead, I get "Unknown error", which means the URL is correct, but i am not able to define where the problem is.)
|
|
hi, URLSession is not one of my strong suits, but i have two ideas. (1) the first debugging step is to catch any error thrown in the JSON decoding, perhaps something like this
(2) i see that you have defined hope that helps, DMG |
|
|
|
Hello delawaremathguy & NigelGee , your reply is highly appreciated.
I revised the code to be
|
|
hi, well, unfortunately, the error "The data couldn’t be read because it isn’t in the correct format" means that the data couldn’t be read because it isn’t in the correct format. (AAARRGGHH!) (1) it would help to see what the data is that you are reading and whether it matches up against your definition. (2) you could use a more informative catch handler. replace the generic catch handler
with this extended one that i have used in the past:
see if that tells you anything more. hope that helps, DMG |
|
Great... sure that told me more, by applying your code, I got this error : type mismatch for type Dictionary<String, Any> in JSON: Expected to decode Dictionary<String, Any> but found an array instead. then i changed this part of code:
MANY MANY THANKS |
|
Tweaks to your original code to make it work. See the comments for explanation of changes.
|
|
|
|
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.