0

使用 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 中设置值,但字典值始终为空,如何解析这个?请帮我。

提前致谢

我试过这个:

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

1 回答 1

0

您使用 SBJSON 是有原因的吗?您可以使用内置解析器:

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

编辑: 你的 Json String 也是无效的。您可以使用这样的网站来检查您的 json

于 2013-02-12T18:05:49.387 回答