-1

我已经使用SBJsonParserandASIFormDataRequest用于发布和 JSON 解析,比如

NSString *urlStr = @"http:facebookpage/second/index.php";
NSURL *log_Url = [NSURL URLWithString:urlStr];

request = [ASIFormDataRequest requestWithURL:log_Url];
[ASIHTTPRequest setSessionCookies:nil];
[request setPostValue:uName.text forKey:@"uname"];
[request setPostValue:passWord.text forKey:@"pwd"];
[request setPostValue:@"login" forKey:@"req"];
[request startSynchronous];

NSError *error = [request error];
if (!error) {
    response = [request responseString];
}
NSLog(@"%@",response);

然后用于解析:

parser = [[SBJsonParser alloc]init ];
json_dic_values = [parser objectWithString:response error:nil];
NSString *status = [json_dic_values objectForKey:@"status"];
Url_pathforPages = [json_dic_values objectForKey:@"url"];
NSString *sessionID = [json_dic_values objectForKey:@"session_id"];

在这里我需要知道如何在 NSJsonSerialization 中做同样的事情。上述方法一切正常....

4

1 回答 1

0

中确实只有几个方法NSJSONSerialization。看看文档。

json_dic_values = [NSJSONSerialization JSONObjectWithData: [response dataUsingEncoding: NSUTF8StringEncoding] options: 0 error: &error];
于 2013-05-30T14:21:22.590 回答