Using SBJSON parser to parse JSON value from server, i have received response like
使用SBJSON解析器来解析来自服务器的JSON值,我收到了类似的响应
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *json_string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
json_string value here:
这里的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" } }
then i tried to set the value in NSDictionary but the dictionar value always null, how to parse this? please help me.
然后我试着在NSDictionary中设置值,但是dictionar值总是为null,如何解析这个?请帮我。
Thanks in Advance
提前致谢
I tried this:
我试过这个:
SBJSON * parser = [[SBJSON alloc] init];
NSDictionary *dic = (NSDictionary *)[parser objectWithString:json_string error:nil];
1 个解决方案
#1
0
Is there a reason you are using SBJSON? You can use the build in parser:
你有没有理由使用SBJSON?您可以使用内置解析器:
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
Edit: Also you Json String is invalid. You can use a site like this to check you json
编辑:你Json String也是无效的。您可以使用这样的网站来检查您的json
#1
0
Is there a reason you are using SBJSON? You can use the build in parser:
你有没有理由使用SBJSON?您可以使用内置解析器:
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
Edit: Also you Json String is invalid. You can use a site like this to check you json
编辑:你Json String也是无效的。您可以使用这样的网站来检查您的json