What is JSON - JSON Parsing in Swift

preview_player
Показать описание
What is JSON and how do you parse JSON in Swift? This video will show you!

JSON stands for JavaScript Object Notation and it's a way to represent data in a standard way. It helps organize that data in a way that machines can "read".

Think about how a dictionary is organized alphabetically and each entry has a word followed by a definition. There's a well defined standard which makes it easy to process the info.

The JSON data format is often used in a data feed or in the returned data from an API call.

Because the data is in a standard data format, our app can "parse" out the information from the data feed or API response.

To understand how JSON is organizes data, you need these 3 concepts:

Key-Value pairs: The key is a label and the value is the actual data. Together, a key-value pair represents one piece of information.

JSON Object: This is a collection of key-value pairs together. Often the key-value pairs are related together so that the collection (JSON object) represents a bigger piece of data. For example, the JSON Object could represent a person and the collection of key-value pairs represents the attributes of the person.

Array: An array in JSON represents a list of JSON objects or other values.

For an example of JSON data, check out the video tutorial! In the video, I also show how to parse JSON in Swift using the Codable protocol.

We take the response JSON data from a real API call and then parse it in Swift!

🚨 SPECIAL CWC+ OFFER FOR YOUTUBE:

MY FREE ONLINE COURSE:

CWC+ PROGRAM:

WEEKLY UPDATES VIA EMAIL:

CONNECT:

ABOUT CODEWITHCHRIS:

#JSON #Parsing #CodeWithChris
Рекомендации по теме
Комментарии
Автор

I had to come back and watch this again. Why? Because people who watched this came to me for help.

*This is a great instructional video* However, it is only one side of the same coin.

The other side of the coin... doing something practical with the JSON data outside the scope of the completion handler. Maybe presenting the data in a tableView and *not* on a background thread. And having that data available when a user selects a tableViewCell.

So many people have come to me because they do not know how to continue where this video leaves off.

People are looking forward to seeing Part 2 of this. Thank you.

gauntletwielder
Автор

Thank you chris I am learning lot from your tutorials. ❤️Love from India🇮🇳

Viral_Meme
Автор

I am literally watching this video while on a bus, heading to the company that contracted me to update their app and implement a functionality that requires exactly what's explained here. Talk about winging it lmao. Thanks Chris 👍

MediArgentum
Автор

Thank you Chris ! It helped me in learning.

rohitoznikam
Автор

Wow, that was really quick! Definitely better than dealing with JSONSerialization.

pistonsky
Автор

Hello Chris, thank you for this video. I am no non programmer and this video helped to explain what JSON is so at least I can understand what my dev team says.

spearlightknight
Автор

I had to parse JSON a couple of Swift versions ago and it was such a PAIN to parse JSON back then, so happy that the Apple developers improved this, so much easier nowadays 👍

Jeppelelle
Автор

you are great man! really great. Because you make your videos touching all required points, topics, subjects while developing the target code, not just copy pasting the code.

superintegrated
Автор

Thank you so much, Chris! This tutorial was very well-paced and gave me the proper context of what was happening. Excited to see what you make next!

sujitmolleti
Автор

Hey Chris thanks a lot for making these great videos, you teach stuff very well and also you say some valuable experience while you teaching such as put some breakpoint or use debug console and also make properties optional. Thanks a lot again

alifarhadi
Автор

Thanks Chris! You are a great instructor!

davetisdale
Автор

Excellent video ... thanks for sharing this ... learning a lot

richardwalters
Автор

I could sure use your help setting up this dispatch API.

AtesotFlavor
Автор

Hi Christ.
It is good and easier to understand parsing Jason to Swift not swiftUI,
I am glad to to understand the basic.
How to creat a json file
Menu
I'd, name, cost, description
as you API..
Thanks

toanuk
Автор

Reddit API or YouTube API. Great tutorial!

JusCJay
Автор

I know it isn't the focus of the video but what is the best way to manage API keys in Xcode?

adamhowley
Автор

Great video, very insightful thank you! Is there anyway, you could do a series on this to go into more detail? I get the general gist but not sure I would be able to replicate on my own. A tutorial in the context of an app that displays the parsed information would be very helpful. Also have you mentioned things like "do catch try" in other videos? This was my first time hearing it and was a bit confusing.

charlesokehie
Автор

A Shopify API would be amazing. Maybe a way to fetch products or something like that

shd
Автор

So why are you choosing to use Swift Storyboards for this demo vs SwiftUI? Is there a difference for how this is done? Thanks!

TylerWasick
Автор

I know I'm late, but would love to see a demo of google earth and/or maps API!

benjamincleek