我有JSON數據如在本示出下面我需要獲得的數據,其鍵值對爲默認值是1,那麼我需要得到剩餘的字典數據和需要被傳遞給用戶顯示任何一個可以告訴我如何實現這個?如何從Json中獲得特定的值?
我的代碼如下所示
if let addressArray = jsonObj!.value(forKey: "address") as? NSArray{
for array in addressArray {
if let addressDict = array as? NSDictionary{
if let Default = addressDict.value(forKey: "default"){
}
}
}
}
"address": [
{
"default": 0,
"number": 9123456711,
"name": "Ramesh",
"address": "No:11/111 ,cross street,Nungambakkam,mylapore,chennai :600088"
},
{
"default": 1,
"number": 8123456722,
"name": "Vignesh",
"address": "No:22/222 ,cross street,Perambur,chennai :600012"
},
{
"default": 0,
"number": 7123456733,
"name": "Rajesh",
"address": "No:33/333 ,cross street,Villivakkam,chennai :600045"
}
]
你完成幾乎你有什麼錯誤?只需添加addressDict成一個陣列,滿足條件的默認1.then使用陣列顯示 –
我需要得到該鍵值對默認爲1,則該數據需要將數據被顯示@DSDharma –
這就是我所問的@DSDharma –