我有一個iOS應用程序尋求站,我想添加燃料價格。我如何解析這個json架構在目標-c
我發現一個Opendata與數據庫,但我不能解析數組「字段」和「price_e10」,只有陣列「記錄」。
這裏的JSON模式的(我認爲這是多維陣列)的例子:
"records":[
{
"datasetid":"prix_des_carburants_j_7",
"recordid":"fa74ca1fdf6938333d2bc1013623b66771557b31",
"fields":{
"price_e10":1.389,
這裏我的代碼在Objective-C的例子:
NSError *e;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseData options: NSJSONReadingMutableContainers error: &e];
NSArray *arrayResult =[dict objectForKey:@"records"];
arraySmpl = [NSMutableArray arrayWithArray:arrayResult];
NSLog(@" MULTIPLE ARRAY : %@ ",arrayResult);
rowsInSection = [arraySmpl count] + 1;
感謝您的幫助
'arrayResult'是NSDictionary的NSArray。對於鍵「字段」,該值是一個「NSDictionary」。 =>'NSString * aprice = [[arrayResult objectAtIndex:??] objectForKey:@「fields」] objectForKey:@「price_e10」'? – Larme