2013-02-12 73 views
0

使用SBJSON解析器解析从服务器JSON的价值,我已经收到响应像如何解析iPad中的JSON值?

-(void)connectionDidFinishLoading:(NSURLConnection *)connection 
{ 

NSString *json_string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 

json_string值这里:

{ "status": true, "result": { "nid": "1116", "title": "PeopleSoft Enterprise HCM 91 Release Notes.pdf", "status": "1", "uid": "1", "body": "\x3cp\x3e\x3ca href=\"http://www.carinsuranceiseasy.com/\"\x3echeapest auto insurance\x3c/a\x3e wttig \x3ca href=\"http://www.lifeinsuranceshopping.net/\"\x3elife insurance quotes\x3c/a\x3e 304 \x3ca href=\"http://www.bestautoinsurancepolicies.net/\"\x3eaffordable auto insurance\x3c/a\x3e 39292\x3c/p\x3e", "splitpdfs": [ ], "mail": "[email protected]", "name": "admin", "pdf": "http://www.publishgenie.com/sites/default/files/pdf_convert/2012/12/19/1355908128-986.pdf", "page_number": "249", "filesize": 8936895, "referrallink": "http://www.publishgenie.com/index.php?q=ebook-referral/530/1116/19f80281e0ad314423afb51a5322e2ac" } } 

然后我试图在NSDictionary的设定值,但dictionar值总是空,如何解析这个?请帮帮我。

由于提前

我尝试这样做:

SBJSON * parser = [[SBJSON alloc] init]; 
    NSDictionary *dic = (NSDictionary *)[parser objectWithString:json_string error:nil]; 

回答

0

是否有您使用SBJSON理由吗?您可以在解析器使用编译:

id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; 

编辑: 你也JSON字符串是无效的。 You can use a site like this to check you json

+0

感谢您的回复 – SampathKumar 2013-02-13 06:07:45