Skip to content
0:00 / 0:00

#codable#json#swift

Encodable and Decodable | Swift 4, Xcode 9

Kilo Loco

35K subscribers • 2 videos on Hallway

YouTube
  • Recommended by 3 people: 3 in engineering communities.
  • Presented by Kilo Loco
  • May be out of date. The tools, versions or practices it shows have likely moved on.

Intermediate. Assumes working knowledge.

29K views9 years ago3 recommendations

Programming languagesMobile developmentSwiftiOS and SwiftUI

Kilo Loco demonstrates how to use the Encodable and Decodable protocols in Swift 4 to parse JSON and make network requests.

Today we go over how to turn encode and decode data models to and from JSON using the Encodable and Decodable protocols with Swift 4. In this tutorial, you will learn how to make a post request using a Data model as a JSON parameter and see how to turn the response back into a data mode. Then we go over how to handle responses that contain arrays, nested objects, and how to access data from those Decodable objects. The majority of apps make networking requests, and the responses to those requests are usually returned in JSON. Knowing how to implement the Encodable and Decodable protocols into you project will allow you to cut back on the boilerplate code of decoding JSON and allow you to keep your code clean (and allow you to code passionately 😉) See what's next on the schedule by checking out my Trello board: trello.com/b/TNhRZsB2/kilo-loco-content-flow The finished project is available to any students of the free YouTube On my website. Make sure you enroll today: kiloloco.com/p/youtube If you have any questions or comments about the tutorial, or want to suggest a video to make, feel free to leave a comment below, or reach out to me on Twitter: twitter.com/kilo_loco If you found this tutorial helpful, make sure to subscribe to the channel for more great tutorials.

Why it's here

3 people recommend this

What people say. Recommended for learning how to use Swift's Codable protocols to easily parse JSON without external libraries.

u/jiqqamanin r/swift • Recommends

On “Parsing JSON help”

The issue is that the tutorial isn’t showing you the network response that returns the data you’re looking for. This should give you a general idea on how to make a request and use the data. Then you can parse the data with the code you’re using. Also, **IF** you’re on Swift 4, checkout Codeable/Decodable. Makes handling JSON so much easier. Youtube Link

u/KarlJay001in r/swift • Recommends

On “Best online course for learning MVC swift?”

Try this guy: link to this video He actually has some good content, but you could reduce this down to about 3 min. I watched on a while back that had to be 2/3 typing. I really don't need to see people type. I messaged one guy about having the source code linked somewhere so we don't have to type it all in. He replied about how it's better to learn if you type it in and "cut and paste" programming was bad. I get that, but I've been programming for many years, I just need to know how something works. I don't need more typing practice. If they could just type everything out in advance, then zoom in, highlight and explain the code, run the code, link the code. IMO, part of the problem is that it'…

u/westopher_robinin r/swift • Recommends

On “Help with a school project”

Awesome! I really like this guy’s tutorials on codable for accessing json: link to this video Codable offers the advantage that you don’t have to use a pod like alamofire or whatever.