2
我想在我的swift代碼中訪問JSON數據,並且無法正確返回它。這裏是我的JSON代碼:在swift中訪問JSON數據
[
{
"id": "1",
"isImage": "0",
"name": "test name",
"post": "test post",
"time": "10:27",
"ip": "192.168.1.1",
"city ": "Columbus",
"latlong": "39.896418,-82.9751105",
"clientID": "clientID",
"popularity": "300"
},
{
"id": "2",
"isImage": "0",
"name": "test name two",
"post": "test post two",
"time": "13:37",
"ip": "192.168.1.1",
"city ": "Columbus",
"latlong": "39.896418,-82.9751105",
"clientID": "clientID",
"popularity": "69"
}
]
我只是想知道如何用自己的鑰匙json[0].['id']
或訪問數據? 我目前使用這個json.swift module,並試圖與
func jsonHandle(data: NSString) {
var parsedJSON = JSON(data)
var id = parsedJSON[0].["id"]
NSLog("\(id)")
}
訪問數據,但它沒有返回。有任何想法嗎?
正是我在找的東西。謝謝。 – uhfocuz 2014-11-25 01:22:23