Parsing JSON in Swift

The new programming language “Swift” introduced by Apple last year comes with various really great features and is much easier to use than its predecessor Objective-C.

However, if you ever came across the “pleasure” of parsing a JSON in Swift you will soon find that it gets really complex.

During our search we found a really great Library called “SwiftyJSON” by tangplin on github. We would like to thank him at this point for providing this cool library.

Parsing a JSON in Swift becomes as easy as something like this:

var durationInSeconds = swifty["routes"][0]["legs"][0]["duration"]["value"].int;
var endAdress = swifty["routes"][0]["legs"][0]["end_address"].string;
var encodedRoute = swifty["routes"][0]["overview_polyline"]["points"].string;

Posted in A Developers Life Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>