我正在尝试从字典中获取一个值。
我有一个有4个条目的字典,第四个条目是一个字典数组。
我知道我想要的值是在数组的最后一个字典中设置的。我怎样才能从中获得一个valee呢?
myDict["a" : String, "b" : String, "c" : String, "d" : [ArrayofDict]]
在ArrayofDict中有["1" : String, "2" : String]
。
我想获取ArrayofDict的第二个值。
至少我认为是这样的。下面是收集到的数据的图像。
在本例中,imgUrl为d,并且我认为是字典的所有4个值在文本=部分中的不同文本中是相同的
发布于 2018-08-19 01:17:15
这似乎是一个包含4个元素的数组的字典,表示关键字"imgUrl“。数组中的每个元素似乎都有两个参数text
和size
。因此,我将根据这种理解重构我的答案。
guard let imageDict = myDict["imgUrl"] as? [Imagess] else { // Image being the Struct created to parse the Json from the website
print("Dictionary not found!"
return
}
guard let imageURL = imageDict.first?.text as? String else {
print("url not found!")
return
}
print(imageURL)
https://stackoverflow.com/questions/51910961
复制相似问题