這是我從服務器收到的JSON響應。我試圖解析值沒有任何成功。如何解析Swift 3中這個JSON響應的值?
{"items":
[{"item":
{ "id":824,
"company_id":31,
"config_id":45,
"imagesmall":null,
"imagethumb":null,
"pointofsales":null,
"status":true,
"endPlanned":false
}
},
{"item":
{ "id":889,
"company_id":74,
.
.
.
"status":true,
"endPlanned":false
}
}]
}
代碼我想
if let json = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String: Any]{
print(json) // does work
let item = json?["items"] as? [[String: Any]]
print(item?[0]) // does work
// ... from here I am looking for the code to access the values and print it out ...
}
告訴我們你試過的東西。 –
不在這裏[編輯您的問題](http://stackoverflow.com/posts/42000176/edit)與您的嘗試代碼和什麼不工作。 –