使用SBJSON解析器解析来自服务器的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": "gumpagain@gmail.com", "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值总是为null,如何解析这个?请帮帮我。
先谢谢
我试过了:
SBJSON * parser = [[SBJSON alloc] init];
NSDictionary *dic = (NSDictionary *)[parser objectWithString:json_string error:nil];
答案 0 :(得分:0)
你有使用SBJSON的原因吗?您可以使用内置解析器:
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
修改强> 你Json String也是无效的。 You can use a site like this to check you json