我的 json 文件看起来像这样
[{"id":"1","category":"New Category1","title":"New Product2","description":"Please type a description1","imgurl":"http:\/\/s.wordpress.org\/about\/images\/wordpress-logo-notext-bg.png","spectitle":"Specification","specvalue":"Value"},{"id":"2","category":"Mobile","title":"Samsung","description":"Please type a description","imgurl":"http:\/\/s.wordpress.org\/about\/images\/wordpress-logo-notext-bg.png","spectitle":"Price","specvalue":"100$"}]
我有 4 个标签,必须在各个标签中打印 id、类别、标题、描述。我已经成功解析了整个 json 对象并打印在一个标签中。我需要将所有具有相应类别的 json 对象显示到相应的标签。
NSString *labelstring =[NSString stringWithFormat:@"%@",[json objectAtIndex:0]];
label1.text=[NSString stringwithformat: objectForKey:@"id"];
label2.text=[NSString stringwithformat:objectForKey:@"category"];
label3.text=[NSString stringwithformat:objectForKey:@"title"];
label4.text=[NSString stringwithformat:objectForKey:@"description"];
这里 json 是 NSArray 的一个变量,具有 URL 信息和那些东西......但如果我试图获得个人价值,我无法得到它......请指导......