我來自php領域,現在學習ios編碼。我想用一個顯示用戶信息的部分和一個顯示朋友詳細信息的表格進行查看。iOS解析jsonDictionary
我可以得到json記錄正確。
我的JSON是這樣的:
{"Me":
{"username":"aVC",
"userID":1
},
"Friends":
[{"username":"Amm",
"userID":2
},...
]
}
這裏是我使用。
NSError *error;
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSDictionary *json = (NSDictionary*)[NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSLog(@"jS: %@", json);
這工作正常。我想分開兩個部分(我和朋友),然後用它來填充表格。有人可以提出一些想法嗎?
注意:我沒有使用任何框架。只是NSJSONSerialization。
使用NSLog檢查字典(它看起來很像原始JSON)。根據需要提取單個字典元素,並進一步處理它們。如果你一次只做一步,那真的很簡單。 – 2013-05-01 02:57:36