Skip to content
0:00 / 0:00

#decodable#jsondecoder#swift

Parsing JSON Just Became Super Easy in Swift 4 with Decodable

Lets Build That App

198K subscribers • 5 videos on Hallway

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

Intermediate. Assumes working knowledge.

275K views9 years ago2 recommendations

Programming languagesMobile developmentSwiftiOS and SwiftUI

A tutorial demonstrating how to transition from JSONSerialization to the native Decodable protocol and JSONDecoder in Swift 4.

Transforming JSON into model objects in your apps just became a whole lot easier with the introduction of Decodable in Swift 4. In today's lesson, I want to walk through the old way of using JSONSerialization and then show you the new JSONDecoder method. We can retire a bunch of JSON serializer pods now that we have this feature natively supported. URLs for JSON blobs: api.letsbuildthatapp.com/jsondecodable/course api.letsbuildthatapp.com/jsondecodable/courses api.letsbuildthatapp.com/jsondecodable/website_description api.letsbuildthatapp.com/jsondecodable/courses_missing_field… Completed Source Code letsbuildthatapp.com/course_video?id=1562 Instagram Firebase Course letsbuildthatapp.com/course/instagram-firebase Facebook Group facebook.com/groups/1240636442694543/ iOS Basic Training Course letsbuildthatapp.com/basic-training Follow me on Twitter: twitter.com/buildthatapp

Why it's here

2 people recommend this

What people say. Recommended as a helpful tutorial for understanding how to parse JSON using Swift's Decodable protocol.

Moments people linked to

u/klarkzenin r/swift • Recommends

On “Using UrlSession with parameters?”

…= "7465be2382c82a728bf78ed04fb3e1d0" let url = URL(string: http://api.openweathermap.org/data/2.5/weather/?q=\(query)&appid=\(apiKey)) You should also remove `allHTTPHeaderFields` and its array as it is unnecessary. I tested using Postman and it returned JSON. Also, with Swifts new Decodable protocol it's far easier to work with JSON. This link to this video helped me understand how to set up a dataTask that parses JSON.…
1View on Reddit

u/donkeykong83in r/swift • Recommends

On “[Help] Swift 4 - How can i extract data from a url which contains a json”

Good video tutorial here link to this video

u/wad11656in r/swift • Mentions

How to print JSONArray->JSONObject->JSONObjectProperty ? import Foundation import UIKit struct damage_relations : Decodable { let double_damage_from: double_damage_from? } struct double_damage_from : Decodable { let name: String? } class Flying: UIViewController{ override func videwDidLoad(){ super.viewDidLoad() let jsonUrlString = "https://pokeapi.co/api/v2/type/flying/" guard let url = URL(string: jsonUrlString) else { return } URLSession.shared.dataTask(with: url) { (data, response, err) in guard let data = data else { return }…