我已经发布了这个帮助,但不幸的是他们都没有为我工作... 任何人都在那里帮助我..请.....如何解析此JSON饲料。我想所有的项目,如'id','title','teaser','body','fid,'filename','filepath'
.........如何解析此JSON供稿?
{
"data":{
"mat_149":{
"id":"149",
"title":"The closing of 40% profit within 9 month",
"teaser":"profit within 9 months only which is equal to 52% annual profit",
"body":" The auction was presented in a very high and commercial lands.\u000d\u000a",
"files":{
"911":{
"fid":"911",
"filename":"22.JPG",
"filepath":"http://mysite/files/22_0.JPG"
}
}
},
"mat_147":{
"id":"147",
"title":"Company launches the city ",
"teaser":"demands for distinguished lands.",
"body":" The area size is quare meters This is evident through projects and many other projects.\u000d\u000a\u000d\u000a",
"files":{
"906":{
"fid":"906",
"filename":"2D7z.jpg",
"filepath":"http://mysite/dlr/files/2D7Z.jpg"
}
}
},
"mat_link":"mysite.com/"
}
}
我用JSON的框架解析这样的:
NSString *response = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding] ;
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *data = (NSDictionary *) [parser objectWithString:response error:nil];
NSLog(@"Data : %@", [data valueForKey:@"data"]);
我得到的数据:
NSLog(@"Data : %@", [data objectForKey:@"data"]);
我想获得的所有项目'id','title','teaser','body','fid,'filename','filepath'
.........请帮我......请.....
NSString *response = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding] ;
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *data = (NSDictionary *) [parser objectWithString:response error:nil];
NSDictionary *filedict = [data valueForKey:@"data"];
for(id key in filedict)
{
NSDictionary *files = [filedict valueForKey:key];
NSLog(@"File ------------------- = %@",files);
}
但问题是。有时候它说
File ------------------- = "<null>";
我有什么做的..帮助我....
难道有时候'files'字段是空的吗? :-)那么有什么要解决的? – DarkDust
你的名字是...讽刺! –
文件的项目是有我的JSON ......它不是空.....请.....它不是空.......文件项是有我的JSON。它不为空... – proCoder