In this Swift tutorial, you will learn how to work with network services and APIs, and how to parse JSON into model objects that can be used in your iOS app.
I will demonstrate how to read basic JSON data and how to write custom Swift model types.
Overview
00:00 Introduction
01:25 Decoding JSON
08:48 Example with JSONPlaceholder API
17:07 Example with cat API
23:44 renaming of properties and CodingKey
27:09 parsing different types with init(from decoder)
31:58 nested JSON data
35:06 fetching more images
39:44 wrap up
Resources:
JSON placeholder https://jsonplaceholder.typicode.com
Cat API https://docs.thecatapi.com/example-by-breed
Books:
Develop in Swift Data Collections, Chapter 2.4
https://books.apple.com/de/book/develop-in-swift-data-collections/?l=en
🤩 Learn more
Part 1: working with the Web, HTTP, JSON, and REST APIs
https://youtu.be/ggEcSzPbVr4
Part 3: Networking in a SwiftUI app
https://youtu.be/ZHK5TwKwcE4
If you liked what you learned and you want to see more, check out one of my courses!
👨💻 my SwiftUI course https://school.swiftyplace.com/courses/swiftui-course
👨💻 my Core Data and SwiftUI course https://school.swiftyplace.com/courses/swiftui-and-core-data
👩🏻💻 Combine course
https://school.swiftyplace.com/courses/master-combine-framework
⬇️ Source Code:
https://github.com/gahntpo/CatAPI-youtube-tutorial
#DecodingJSON #JSON #Swift #ParsingJSON #Codable