ios - how to get data from JSON array SwiftyJSON? -
i able data json array: here below, trying show earliest > date
func parsejsontowns() { let url = nsurl(string: "https://api.tfl.gov.uk/journey/journeyresults/\(selectedstation)/to/\(selectedstation1)") let jsondata = nsdata(contentsofurl: url!) let readablejson = try! nsjsonserialization.jsonobjectwithdata(jsondata!, options: []) as! [string:anyobject] let object = json(readablejson) let searchcriteria = object["earliest"] option in searchcriteria.arrayvalue { let commonname = option["date"].stringvalue commonnamearray.append(commonname) } selectedstation = selectedstation.stringbyreplacingoccurrencesofstring("%20", withstring: " ") numberofrows = commonnamearray.count nslog("\(url)") nslog("number of rows: \(numberofrows)") }
the date
of earliest
in dictionary timeadjustments
in dictionary searchcriteria
let object = json(readablejson) let earliest = object["searchcriteria"]["timeadjustments"]["earliest"]["date"].stringvalue print(earliest)
Comments
Post a Comment