futurice / ios-good-practices

Good ideas for iOS development, by Futurice developers.
http://www.futurice.com
Other
10.83k stars 1.24k forks source link

JSON Parsing best Practice? #78

Closed AliKarpuzoglu closed 5 years ago

AliKarpuzoglu commented 5 years ago

I think the Codable type is preferred to the Libraries. (since swift 4)

https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types

abrahamduran commented 5 years ago

I have to admit, that at the beginning it wasn't that easy to make the transition to Codable. And many times I wish to go back to "easier" approaches like SwiftyJSON. Especially when dealing with an API with so many flaws and bad practices in their JSON responses, like no consistency in structure, response, dynamic keys, etc.

But, in the end, Codable proved to be really great to use. The Codable API is really robust and able to cover many edge cases. I didn't need to go back to other JSON parsing techniques or implement workarounds for those edge cases.

mkko commented 5 years ago

Definitely, it's a great addition to Swift. There's a PR #69 dealing with this deficiency.

theapache64 commented 5 years ago

PR #69 Merged. I think we can close this issue now.