How do I parse an array inside parsed JSON in Swift? How do I parse an array inside parsed JSON in Swift? ios ios

How do I parse an array inside parsed JSON in Swift?


Dictionary access in Swift returns an Optional, so you need to force the value (or use the if let syntax) to use it.

This works:parsedJSON["boards"]![0]

(It probably shouldn't crash Xcode, though)


Take a look here:https://github.com/lingoer/SwiftyJSON

let json = JSONValue(dataFromNetworking)if let userName = json[0]["user"]["name"].string{    //Now you got your value}


You can create a variable

var myBoard: NSArray = parsedJSON["boards"] as! NSArray

and then you can access whatever you have in "boards" like-

println(myBoard[0])


matomo