【发布时间】:2016-12-07 05:26:57
【问题描述】:
JSON
{
"321" : {
"title" : "xyz",
"pageid" : 321,
"ns" : 0
},
"172" : {
"pageimage" : "xyzc.jpg",
"pageid" : 172,
"title" : "xyzcc",
"ns" : 0,
"thumbnail" : {
"width" : 100,
"height" : 57,
"source" : "https:\/\/upload.abcd.org\/wikipedia\/commons\/thumb\/d\/de\/xyz.jpg\/100px-xyz.jpg"
}
},
"224" : {
"pageimage" : "abc.jpg",
"pageid" : 224,
"title" : "dasf",
"ns" : 0,
"thumbnail" : {
"width" : 98,
"height" : 100,
"source" : "http:\/\/example.org\/images\/thumb\/2\/26\/skfdb.jpg\/98px-586px-dasdfsa.jpg"
}
},
"825" : {
"title" : "efkjdsb",
"pageid" : 825,
"ns" : 0
},
"229" : {
"title" : "eafewg",
"pageid" : 229,
"ns" : 0
}
使用SwiftyJSON从JSONresponse检索后如何访问JSON文件中的“title”和“thumbnail”:“source”?
“321”、“172”可以改变和依赖。相同格式的数组中有多个对象。
有些对象有缩略图对象,有些则没有。
如何将title 和thumbnail->source 提取到带有图像和标签的TableView 以创建列表。
(使用Swift 语言)
我正在使用 AFNetworking 检索 json
let manager = AFHTTPSessionManager()
manager.GET(url, parameters: nil, success: {(operation, responseObject) -> Void in
let responsejson = JSON(responseObject!)
print("\n \n \n \n \n \n Retrieved = \n\(responsejson)")
let items = responsejson.count
print("Items : \(items)")
提前致谢。
【问题讨论】:
-
向我们展示您的尝试。
-
我面临的问题是由于每个对象数组的索引都带有数字。因此我无法获取它们。
-
我没有要显示的代码。因为我是 ios 中这种 json 格式的新手
-
@NiravD 如果你熟悉,可以帮我解决这个问题
-
为此,您至少需要展示如何获得此 JSON 响应。
标签: ios json swift afnetworking swifty-json