Skip to content

Instantly share code, notes, and snippets.

@Prate-k
Last active March 3, 2019 11:36
Show Gist options
  • Save Prate-k/5e98d3e9284545e0df9385f74733f54e to your computer and use it in GitHub Desktop.
Save Prate-k/5e98d3e9284545e0df9385f74733f54e to your computer and use it in GitHub Desktop.
Accessing JSON values with the known keys from JSON response
if let query = json["query"] as? [String:Any] {
if let pages = query["pages"] as? [String:Any] {
if let page = pages["30984"] as? [String:Any] {
if let revisions = page["revisions"] as? [[String:Any]] {
if let element = revisions[0] as? [String:Any] {
if let htmlData = element["*"] as? String {
print(htmlData)
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment