Handling JSON data can be difficult using Swift because of Swift’s strictness with types.
Here’s a library that makes handling Swift in much easier called SwiftyJSON from Ruoyu Fu.
SwiftyJSON makes things much simpler automatically handling different types of data.
This example from the readme shows the mess caused from using NSJSON to handle parsing the user and name from JSON data even when using chaining:
if let userName = (((jsonObject as? NSArray)?[0] as? NSDictionary)?["user"] as? NSDictionary)?["name"]{
//What A disaster above
}
While with SwiftyJSON you could use something like:
if let userName = json[0]["user"]["name"].string{
//Now you got your value
}
SwifyJSON also handles wrapping of values, and handling incorrect keys.
You can find SwiftyJSON on Github here.
A nice library for working with JSON with Swift.
- An Extensive Open Source iOS Library For Working With The Twitter API Written In Swift
- Open Source Functional Programming Toolbelt For Swift Inspired By The Underscore.js Library
- An Open Source Swift Library For Easily Creating Much More Useful Logging Statements
- Free Tool That Automatically Converts JSON Models To Objective-C Objects And Core Data Models
- Open Source: Active Record Library For SQLite Databases In iOS Apps
Original article: An Open Source Library That Makes Working With JSON Data Using Swift Much Easier
©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.




