Working with JSON! (Swift in Xcode)

Jared Davidson · 77K views · 2015 · 20:45

Open on YouTube

Software practice, open source & careersWeb developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering or asking about parsing local JSON files in Swift with SwiftyJSON, and as a starting point for storing data in an iOS app.

Recommended by 2 people across 2 different months, 2015 to 2017.

What it is

A 2015 Xcode screencast by Jared Davidson showing how to read and parse a local JSON file in Swift using the SwiftyJSON library. It walks through loading the file from the app bundle and pulling values out of the parsed structure.

What people said

Recommends Gabo Cuadros Cardenas · 2015-08 · Stack Overflow · on “swiftyJSON parsing json from NSURL”

swiftyJSON don´t works with URL´s , swiftJSON works perfectly with local data this is a tutorial that you can see to understand more the swiftJSON [this video] to parse the JSON from the web you need to do that... [LINK]

Recommends Yassine En · 2017-03 · Stack Overflow · on “Store data in IOS project”

If you would to create a DataBase, you can use a local JSON (see this tutorial [this video] ) or you can use .plist

Cites Omid · 2016-03 · Stack Overflow · on “Swift 2 parse JSON from an online URL with swiftyJSON”

I watched the Jared Davidson's video about parsing JSON with SwiftJSON. I followed this video : [this video] IT WAS WORKING FINE !! ... but the JSON file was a local file. Now I want to move this file to my website ! This was my code before trying to use a remote JSON file (this code was working very well) : let path: String = NSBundle.mainBundle().pathForResource("Database", ofType: "json") as String! let jsonData = NSData(contentsOfFile: NSURL(string: path) as NSData! let readableJSON = JSON(data: jsonData, options: NSJSONReadingOptions.MutableContainers, error: nil) // Récupère et classe les élèment de la date let title = readableJSON["dates"][todayDate]["title"].string as String! To be able t

Cites Sami · 2016-11 · Stack Overflow · on “(Swift3) Can return the full JSON file but I cannot return a specific value, what am I doing incorrectly?”

I have a local JSON file named as such: testTheJSON.json {"myJSON": [{ "ID1" : {"name":"Stack", "LastName": "Overflow" }, "ID2" : {"name":"Cat", "last":"dog", } } ] } and I try to read in the file as such: func parseJSON() { let path = Bundle.main.path(forResource: "testTheJSON", ofType: "json") let jsonData : NSData = NSData(contentsOfFile: path!)! as NSData! let readableJSON = JSON(data: jsonData as Data, options: JSONSerialization.ReadingOptions.mutableContainers, error: nil) var name = readableJSON["myJSON","ID1","name"] print(readableJSON) //returns the full JSON script print (name) //returns null } Why does print(readableJSON) return the full JSON file and print(name) return as null? A