Parse API Data using structs and swift decodable protocol

With the encodable and decodable protocols coming to swift 4, it will just be a matter of time before the example code written is deprecated. How would you create a struct model and go through the data using decodable with your api?


  • AmosDuveenAmosDuveen Member, Administrator, Moderator admin

    Hi @dh_selbee344,

    We will continue to display our sample code while it remains useful. Meanwhile, one of our tech team pointed me to this article which might help you with difficulties you might be having with Swift 4.

  • @dh_selbee344 did you manage to work with the data received?

    Because the example code they have is getting me some "JSON" data that isn't JSON at all.

  • AmosDuveenAmosDuveen Member, Administrator, Moderator admin

    Hi @salmeda_nieves60,

    Can you please be a bit more specific regarding what issues you are having so that I can have a look to see what's wrong?

  • @AmosDuveen I already managed to make it work. But it was that the jsonSerialization was returning me the JSON as a NSObjectArrayI so i instead used the Alamofire networking library to make the request and managed to get the JSON properly.

  • jnorstrom255jnorstrom255 Member

    @salmeda_nieves60 I'm trying to get this to work with Swift as well. I implemented Alamofire, but was running into some kinda authentication error.

Sign In or Register to comment.