我想分析這樣的json:Json解析沒有根對象
我想獲得特定婚禮或儀式的Photo_name。
我想保留一些照片名稱的婚禮和其他照片名稱陣列名稱。
{
-f1: {
Photos: {
Wedding: [
{
Photo_id: "99",
Photo_name: "2WLB4cSJtg.jpg",
User_id: "11",
Date: "0000-00-00"
},
{
Photo_id: "97",
Photo_name: "EjOCbkWwmF.jpg",
User_id: "11",
Date: "0000-00-00"
},
{
Photo_id: "90",
Photo_name:"18e7af197f2060ad1c58d95c38f16ecc.jpg",
User_id: "11",
Date: "2013-07-24"
}
],
Ceremony: [
{
Photo_id: "96",
Photo_name: "hTWiAQUDnL.jpg",
User_id: "11",
Date: "0000-00-00"
},
{
Photo_id: "92",
Photo_name: "529753_425904027490910_737057237_n.jpg",
User_id: "11",
Date: "2013-07-24"
},
{
Photo_id: "93",
Photo_name: "yCbKG8txQY.jpg",
User_id: "11",
Date: "0000-00-00"
},
{
Photo_id: "94",
Photo_name: "k9goxnlscT.jpg",
User_id: "11",
Date: "0000-00-00"
},
]
}
}
}
此代碼給我F1鍵並顯示JSON的一切,值:
NSString *str=[[NSString alloc]initWithBytes:[webdata mutableBytes] length:[webdata length] encoding:NSUTF8StringEncoding];
NSMutableDictionary *result = [NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
for (id thekey in result) {
NSLog(@"KEY %@ VALUE %@",thekey,[result valueForKey:thekey]);
}
json顯示無效 –
其有效..它與Android一起使用 –
當且僅當密鑰必須包含「」和「,」在末尾時纔有效 –