我是iphone和json世界的新手。我有這個JSON結構。你可以在這裏把它看得很清楚http://jsonviewer.stack.hu/。解析json的麻煩
{"@uri":"http://localhost:8080/RESTful/resources/prom/","promotion":[{"@uri":"http://localhost:8080/RESTful/resources/prom/1/","descrip":"description
here","keyid":"1","name":"The first
name bla bla
","url":"http://localhost/10.png"},{"@uri":"http://localhost:8080/RESTful/resources/promo/2/","descrip":"description
here","keyid":"2","name":"hello","url":"http://localhost/11.png"}]}
我想用json-framework解析它。我試過這個
NSDictionary *json = [myJSON JSONValue];
NSDictionary *promotionDic = [json objectForKey:@"promotion"];
NSLog(@" res %@ : ",[promotionDic objectAtIndex:0]);
但是怎麼做才能得到例子,索引0的對象的名字?我想我應該把對象放在NSArray中?但我不知道如何:/和我不對象的數量是可變的。請幫助 。
謝謝你,它的工作:) – user761812 2011-05-22 19:13:12