-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Looping not working #64
Comments
Yeah I am just using the master version. Isn't it a bit of a problem that the readme is not in sync with the code though? I did eventually get looping to work in this fashion:
|
@vvrinne You code will loop twice, one time to get //If json is .Array
//The `index` is 0..<json.count's string value
for (index: String, subJson: JSON) in json {
//Do something you want
} You should code like this: for (_, entry) in json["data"] {
let id = entry["id"]
let title = entry["title"]
println("\(id) : \(title)")
} OR: for var index = 0; index < json["data"].cout; index++ {
let entry = json["data"][index]
let id = entry["id"]
let title = entry["title"]
println("\(id) : \(title)")
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am following the example for looping through a JSON response. Creating the initial JSON object works and I am able to fetch properties. When I try to loop through the root Dictionary XCode complains that: Type 'JSON' does not conform to protocol 'SequenceType'
I am using Alamofire to make the HTTP request. Here is my response handler:
request.responseJSON { (request, response, data, error) in
let json = JSON(object: data!)
for (key: String, subJson: JSON) in json {
println(subJson)
}
}
The text was updated successfully, but these errors were encountered: