In the video you go print(websiteDescription.name, websiteDescription.description) But if you also wanted to print the first course how would you go about doing that?
You can use websiteDescription.courses.first. We go through a lot about model objects and arrays in the Instagram course if you're interested in learning how this all work in iOS and Swift: www.letsbuildthatapp.com/course/instagram-firebase
Great video, Brian! I like how you taught it from the simplest scenario to more and more complex. This helped me out with my next story card at work. 😃
This is so beautiful that it makes me want to cry! 😂 Just a suggestion but you may want to do the JSONEncoder to compliment this video 😉 I will eventually do my own little tut on these videos as well. Just trying to be like you. Keep up the great work 👍🏽
For those people who are following this tutorial this day. You have to add "number_of_lessons" in the struct after the 1st given link to prevent an error. Hehe -- Hi Brian! thanks for all the tutorials. Swift learner here from Philippines.
Thanks man, i love the way you teach its just awesome. I just want to let you know that your teaching is great and your work is touching this side of Africa. I am able to teach and pass some skills to my peers back here in Zimbabwe.Keep up the great works brother.
Thanks Brian! It has been a long time I was looking web to find a good tutorial about parsing JSON in Swift and here it comes the most simple way to do so! Cheers Man
Great tutorial. Nice voice and cadence. I love how you started with clearly explaining an easy example and then moved to more complex versions. Hitting subscribe was an easy choice. Thank you!
Thank you so much for this tutorial, I have looked all over the place for something that explains how to grab data from a JSON file that actually works and this the best thing I found. Thank you so much for creating this. 👍
Thank you so much for explaining how to handle different types of JSON parses! Your video helped me solve two issues I came across. Helped me a lot. Very well spoken too!
My mind is blown away again. It's a pity I kinda stopped coding lately, due to lack of programmers (in Swift) around me. I must get back to it because I was enjoying it so much. Probably Meetup gonna be my friend in terms of finding ppl with the same interest.
You explain things in a very nice way. Thankyou. I've encountered really unintuitive tutorials on parsing JSON through alamofire into a data model. Came across this and I think I'll just go with this method instead.
Better late than never....happy fourthComing! This video is so awesome, great timing as always and no more depending on swiftyJson, Tron or Json code. Swift 4.0 is definitely the future proof way! Thanks Brian 👍🏻
If only I found this video an hour ago lol. I had to figure this out myself. Great Video Tutorial man! I did not know about the Optional trick in the stuct. Thanks for the tip! My next task is to take the array of objects and load it into core data. :)
Thanks a lot Brian, this is definitely a valuable information, having the fact i spent a complete day on mastering the old way, this is now done very easily and clean, and like you said, it makes the use json parsing cocoa pods redundant. Big thumbs up
By the way Brian, I'm confused about one thing. You've used in your tutorial the struct type in order to express an object, where lately i've been seen it more and more, and especially in Swift's documantation. Is it becoming a convention to express objects rather than creating normal classes?
Thank you so much for this easy tutorial. really helped a lot understanding JSON parsing. Really like the way you teach concepts and make it so easy for us to understand.
Love this video, helped me a ton. One request, I would be nice to end up with a cleaned up version, it was a little messy with a ton of left over comments throughout the code. This is a minor thing, this helped me solve my JSON problems!
Bare in mind this is my first app ever, just meant to try out json :) there are a few small bugs in it, but the idea with the json works like a charm. import UIKit struct Joke: Decodable { let category: String? let icon_url: String? let id: String let value: String } class ViewController: UIViewController { var jokeValue = "" override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBOutlet weak var JokeArea: UILabel! @IBAction func OneMoreTapped(_ sender: UIButton) { fetchJoke() self.JokeArea.text = jokeValue } //this function is fetching the json from URL func fetchJoke(){ let apiURL = "api.chucknorris.io/jokes/random" guard let url = URL(string: apiURL) else { return } URLSession.shared.dataTask(with: url) { (data, response, err) in guard let data = data else { return } do { let joke = try JSONDecoder().decode(Joke.self, from: data) self.jokeValue = joke.value } catch let jsonerr { print("Error caught:", jsonerr) } }.resume() } }
Great video! Loving XCode 9 so far. Found a couple bugs which I've reported, but still very nice. Swift 4.0 though, so glad apple went back to collections with Strings!
Awesome video :D looking forward to Swift 4 and all the new stuff that is going to be included. Swift is becoming such a beautiful language to code in.
Amazing tutorials. Just subscribed. Can you please make a video of how to setup a project? I mean how you organize your classes and logic and stuff. It would be really great to hear from such a pro like you.
Hey Brain, first I just want to say that this a great video and clearly explains how to parse JSON Object data easily in swift 4. Now to my issue, how you handle data JSON Object Data which returns multiple arrays. I have tried to use multiple structs to handle this but I am getting really confused.
First, thank you Brian for the great tutorial! I kept getting an error in the do-catch block, I had to make the properties inside the struct objects optionals for the entire tutorial.
Hey Jorge, I would suggest finding out why you are getting the errors in the do-catch. My hunch is your property names are not spelled correctly. I would also recommend using let declaration instead of var optional whenever possible. This is because you don't want to have mutable properties on objects that shouldn't change. More on this perhaps in another video.
your videos are so awesome. Please make a video on how to upload multiple images to REST server. Searched a lot in youtube and also in stack overflow but couldn't find any proper solution. Thanks
Hey Brian, thanks for the amazing tutorials, I have been a big follower for some time now and love it when new content comes up. Just regarding this, its a simple question hopefully: Do you always have to construct a struct model to match the JSON, even if there are elements within the JSON your not interested in?
Hey man, love the videos! I noticed how the bass is always very low on your videos. I've watched other youtube videos and the equalization is fine on my end. Not sure if anyone else noticed this, but just a heads up!
Very nice video! I've just recently subscribed to your channel. I've been watching your videos daily now. But I've got a question, why are you using structs instead of classes? Is there a reason for that? I might be missing your explanation on it if you've explained it somewhere on your other videos. Anyway, thank you for all of your efforts on making these awesome tutorials! Cheers!
Hi, hope you are doing well. I love to watch your tutorials. I have a quick question for you ? Which camera 📷 do you use for your tutorial making purpose ? And how do I install those tools if I want to make tutorial? Please when you get chance reply me . Thanks be safe ?
I recently saw your video on using generics in networking (thanks again by the way) and it made me check out this approach. With automatic conversion from snake case, it does save a lot of time!
Hello Brian, It's really awesome what you do with your guides, very helpful, can't thank you enough, and I would like to ask you regarding this video, how do I handle multiple naming conventions that are coming from multiple json sources, for me it's not always a happy scenario as I need to parse multiple json sources to same object.
Lets Build That App I came across enum CodingKeys, that can be defined in the struct to match different naming in json, could you please show us how that works in a video ? ☺️
In the video you go print(websiteDescription.name, websiteDescription.description)
But if you also wanted to print the first course how would you go about doing that?
You can use websiteDescription.courses.first. We go through a lot about model objects and arrays in the Instagram course if you're interested in learning how this all work in iOS and Swift: www.letsbuildthatapp.com/course/instagram-firebase
Ahh thank you. And then if you just wanted to print out the names of each of the courses you'd need to make a loop?
Yeah you'd just use some kind of for loop or forEach on the array. We do something very similar with the Posts objects in the course.
I shall check it out now :)
Like this, right?
let courses = try JSONDecoder().decode([Course].self, from: data)
print(courses.count)
for jsonData in courses {
print(jsonData.name!)
}
I'm new to Swift and have spent hours trying to parse an array of object in JSON. Thank you sooooooo much!
Great video, Brian! I like how you taught it from the simplest scenario to more and more complex. This helped me out with my next story card at work. 😃
Great to see you Mark :) I follow both of you with pleasure.
good to see you here mark
I wish someone of you guys talk about App lifecycle and view lifecycle
This is so beautiful that it makes me want to cry! 😂 Just a suggestion but you may want to do the JSONEncoder to compliment this video 😉 I will eventually do my own little tut on these videos as well. Just trying to be like you. Keep up the great work 👍🏽
For those people who are following this tutorial this day.
You have to add "number_of_lessons" in the struct after the 1st given link to prevent an error. Hehe
--
Hi Brian! thanks for all the tutorials. Swift learner here from Philippines.
It has become hard for me to pass by any of your videos without giving it a *LIKE*.
Some awesome content here.
Thanks man, i love the way you teach its just awesome. I just want to let you know that your teaching is great and your work is touching this side of Africa. I am able to teach and pass some skills to my peers back here in Zimbabwe.Keep up the great works brother.
Great to see this channel helping out all the way across the globe.
Thanks Brian! It has been a long time I was looking web to find a good tutorial about parsing JSON in Swift and here it comes the most simple way to do so! Cheers Man
Great tutorial. Nice voice and cadence. I love how you started with clearly explaining an easy example and then moved to more complex versions. Hitting subscribe was an easy choice. Thank you!
Thank you so much for this tutorial, I have looked all over the place for something that explains how to grab data from a JSON file that actually works and this the best thing I found. Thank you so much for creating this. 👍
Thank you so much for explaining how to handle different types of JSON parses! Your video helped me solve two issues I came across. Helped me a lot. Very well spoken too!
It was actually simple. I really enjoyed this tutorial and understood it
Dear Brian, I watch this video many times thanks a lot this help me to build my project
Thanks man, you saved my life! I was going through dozens of shitty examples how to parse json, but it's brilliant
My mind is blown away again. It's a pity I kinda stopped coding lately, due to lack of programmers (in Swift) around me. I must get back to it because I was enjoying it so much. Probably Meetup gonna be my friend in terms of finding ppl with the same interest.
Indeed Swift programming is a lot of fun, hope to see you back in it.
Just imagine what is swift 5 gonna be? This is awesome. Thank you!
You explain things in a very nice way. Thankyou. I've encountered really unintuitive tutorials on parsing JSON through alamofire into a data model. Came across this and I think I'll just go with this method instead.
Better late than never....happy fourthComing! This video is so awesome, great timing as always and no more depending on swiftyJson, Tron or Json code. Swift 4.0 is definitely the future proof way! Thanks Brian 👍🏻
If only I found this video an hour ago lol. I had to figure this out myself. Great Video Tutorial man! I did not know about the Optional trick in the stuct. Thanks for the tip!
My next task is to take the array of objects and load it into core data. :)
You have taught me almost everything I know about IOS development Brian, thanks for another great video!
Thanks a lot Brian, this is definitely a valuable information, having the fact i spent a complete day on mastering the old way, this is now done very easily and clean, and like you said, it makes the use json parsing cocoa pods redundant. Big thumbs up
Indeed, I'm looking forward to having one less pod dependency.
By the way Brian, I'm confused about one thing.
You've used in your tutorial the struct type in order to express an object, where lately i've been seen it more and more, and especially in Swift's documantation. Is it becoming a convention to express objects rather than creating normal classes?
Useful video man, thank you. Didn't think I'd watch the full 19 mins but I did.
19 mins is a long time, hope you were able to either grab breakfast or dinner during it.
Thanks Brian for such a nice video. Really looking forward to see more videos from your side
Thanks so much!!! Took me no time at all to get the job done!
Finally understood this concept. Thanks a ton, mate! God bless.
Had to rewatch this, really good and still actual
Damnnnn This guy programs like a BOSS, i'm impressed Brian
hope to reach your level one day.
Just years of coding repetition, nothing too fancy.
This was a fantastic video. Please keep doing your thing here
Thank you so much for this easy tutorial. really helped a lot understanding JSON parsing. Really like the way you teach concepts and make it so easy for us to understand.
This is amazing...I actually learning lots of things from you..thanks a ton for posting tutorials and sharing knowledge. You are awesome.
Aaaaaaand this was just what I needed to parse the response from an HTTP GET request. Thank you so much Brian!
Super easy and fast right?
Great tutorial!
You made simple what others complicate a lot.
muchas, muchas gracias por tu video, estoy comenzando a programar en este lenguaje y me has ayudado demasiado, muchas gracias
Love this video, helped me a ton.
One request, I would be nice to end up with a cleaned up version, it was a little messy with a ton of left over comments throughout the code. This is a minor thing, this helped me solve my JSON problems!
Cool, what does your cleaned up version look like?
Bare in mind this is my first app ever, just meant to try out json :) there are a few small bugs in it, but the idea with the json works like a charm.
import UIKit
struct Joke: Decodable {
let category: String?
let icon_url: String?
let id: String
let value: String
}
class ViewController: UIViewController {
var jokeValue = ""
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBOutlet weak var JokeArea: UILabel!
@IBAction func OneMoreTapped(_ sender: UIButton) {
fetchJoke()
self.JokeArea.text = jokeValue
}
//this function is fetching the json from URL
func fetchJoke(){
let apiURL = "api.chucknorris.io/jokes/random"
guard let url = URL(string: apiURL) else {
return
}
URLSession.shared.dataTask(with: url) { (data, response, err) in
guard let data = data else { return }
do {
let joke = try JSONDecoder().decode(Joke.self, from: data)
self.jokeValue = joke.value
} catch let jsonerr {
print("Error caught:", jsonerr)
}
}.resume()
}
}
thumbnail was very tempting !
Great video! Loving XCode 9 so far. Found a couple bugs which I've reported, but still very nice. Swift 4.0 though, so glad apple went back to collections with Strings!
Thanks! Very cool and informative video of new JSON parsing feature in Swift4! Subscribed!
Excellent work Brian!
man, your series is wicked, keep it up!
Your teaching videos are super insightful! Thank you!
Glad you find it useful to learn about Swift 4 and JSON.
You're a wizard Brian!
Awesome video :D looking forward to Swift 4 and all the new stuff that is going to be included. Swift is becoming such a beautiful language to code in.
Swift is indeed one of my favorite languages to date.
watch this bro
th-cam.com/video/RIxaANQ2Ijc/w-d-xo.html
Amazing tutorials. Just subscribed. Can you please make a video of how to setup a project? I mean how you organize your classes and logic and stuff. It would be really great to hear from such a pro like you.
Thank you sir! Very useful to me and covered all the things I was concerned about when building me own app. Keep up the great work!
Nice, simple and easily understandable tutorial ! keep going bro
First video I watched from you. Really great!
Fcfb
Hey Brain, first I just want to say that this a great video and clearly explains how to parse JSON Object data easily in swift 4. Now to my issue, how you handle data JSON Object Data which returns multiple arrays. I have tried to use multiple structs to handle this but I am getting really confused.
First, thank you Brian for the great tutorial! I kept getting an error in the do-catch block, I had to make the properties inside the struct objects optionals for the entire tutorial.
Hey Jorge, I would suggest finding out why you are getting the errors in the do-catch. My hunch is your property names are not spelled correctly. I would also recommend using let declaration instead of var optional whenever possible. This is because you don't want to have mutable properties on objects that shouldn't change. More on this perhaps in another video.
You're so awesome!!! btw you might need pop filter or HPF on your EQ.
Hey! You're really clever. Thank you very much for this tutorial. Your explanation are very well to understand although all this stuff is complicated.
Thanks for this tutorial Brian. Simply awesome!
Thanks Brian. Your tutorials always help me many times :)
Nicely explained every part of it. Good one.
one of the best tutorial for API's , thanks man
You inspire me man. Thank you for these videos.
Great review! How to determine a JSON type (array or object) before applying a proper Decoding protocol?
Thank you so much for the best tutorial ever.
wow,, Wondering what they are gonna make it in swift 5!! (let course = data)
I think Swift 5 is going to be even better so lets see next year.
I doubt that otherwise really dumb people might be able to start programming in swift
Swift 4 is much more
th-cam.com/video/RIxaANQ2Ijc/w-d-xo.html
You mean... perhaps they will make it as easy as in Javascript, PHP or Python?
Great video, easy to understand and great explanation..Love it
Great video! It's way less confusing now. Thank you thank you!! :)
your videos are so awesome. Please make a video on how to upload multiple images to REST server. Searched a lot in youtube and also in stack overflow but couldn't find any proper solution. Thanks
so good. It's really helpful for the Beginner programmers. thx a lot. :D
This is what i was looking for, thanks man.
Great Video Brian, small point don't know if really matters; but not sure you should show your aws access key to the world next time.
That was Hilarious . i was using a way long method to parse a simple JSON API's Thank You!
This is so helpful, Super clear and concise Thanks you
Thanks i got my issue you'r video really help full for me many time.
Such a Gud tutorial...Parsing is easy task in Swift 4
Hey Brian, thanks for the amazing tutorials, I have been a big follower for some time now and love it when new content comes up.
Just regarding this, its a simple question hopefully: Do you always have to construct a struct model to match the JSON, even if there are elements within the JSON your not interested in?
This is Amazing , Good bye SwiftyJSON , I will re-write my code to this way
Its the end of SwiftyJson...
One less dependency!
and I like swift 4 parsing much more then released in SwiftyJson.
I've been using Unbox. And I might still use it for some time, until Swift 4 goes final. I find it easier to use than SwiftyJSON, for most tasks.
Then what about this
th-cam.com/video/RIxaANQ2Ijc/w-d-xo.html
This was a great tutorial! I really appreciate your help.
Great video creating struct in a view controller seems very tightly coupled. Wouldn't it be better to make the struct in its own file?
This is just an instructional video, you can put the files wherever you like.
@@LetsBuildThatAppTrue. Thanks again for this video it was great.
It's like a meditation so relaxing ... )
Hope you didn't fall asleep.
Thank you love your tutorials!
Hey man, love the videos! I noticed how the bass is always very low on your videos. I've watched other youtube videos and the equalization is fine on my end. Not sure if anyone else noticed this, but just a heads up!
Yeah, can you watch the latest video on the channel and tell me if the bass is still low? I've since toned down the post effects on the audio.
You are correct! You're latest videos are equalized nicely. Thanks again for the great videos!
Excellent, thanks for helping to confirm this.
Thank you ! Because of your video now i love swift more more than android
Both Android and Swift are good platforms, I find myself enjoying Android programming more these days mostly due to how great Android Studio is.
W8 you make Android :) proud to be first view
I just implemented JSON parsing with Swift 3, but that new way in Swift 4 saves so much code. I'll need to upgrade my Xcode.
Excellent tutorial! Very on point!
I am really thankful for such a great video. It's really helpful. I can't wait for Xcode 9 stable version :)
Another great video brian. Thank you.
Great video sir your all videos are very helpfull thank you
Very good! straight to the point!
This tutorial is awesome man! Subscribed and liked video, You're awesome, thank you so much!
Thats amazing. Appreciate that you shared your knowledge. 👍
Holy cow babies, that is so clean.
good stuff... can u make tutorial about how to display data based on user login with json?
Very nice video! I've just recently subscribed to your channel. I've been watching your videos daily now. But I've got a question, why are you using structs instead of classes? Is there a reason for that? I might be missing your explanation on it if you've explained it somewhere on your other videos. Anyway, thank you for all of your efforts on making these awesome tutorials! Cheers!
+Tity Septiani in general you use structs and if you need a class you turn it into one
Great tutorial, THANK YOU!
RIP Alamofire and SwiftyJSON.
Hi, hope you are doing well. I love to watch your tutorials. I have a quick question for you ? Which camera 📷 do you use for your tutorial making purpose ? And how do I install those tools if I want to make tutorial? Please when you get chance reply me . Thanks be safe ?
You're just a magician
Awsome. this video very helpfull for me as a new be using Swift. Thank you
Very nice video
Brian
Super coder...
Hats off to you man..
Having done this for so many years it becomes second nature. Coding this out without recording is even faster.
I kind of like the old-school way of parsing JSON 😄
I sometimes prefer old school dictionaries as well.
I recently saw your video on using generics in networking (thanks again by the way) and it made me check out this approach. With automatic conversion from snake case, it does save a lot of time!
great video man ...been subbed since 8k
Awesome, I've been subbed since 1 person -_-
Smooth as breeze.. Thanks a lot!!
Great stuff Brian, thanks a lot!
Hey Brain, can you do a tutorial on ARKit
😆
Hello Brian,
It's really awesome what you do with your guides, very helpful, can't thank you enough, and I would like to ask you regarding this video, how do I handle multiple naming conventions that are coming from multiple json sources, for me it's not always a happy scenario as I need to parse multiple json sources to same object.
You'd probably have a consolidation step after you parse from different sources.
Thank you.
Lets Build That App I came across enum CodingKeys, that can be defined in the struct to match different naming in json, could you please show us how that works in a video ? ☺️