0

我已经研究过 SBJSON 解析,效果很好。现在,我正在做 SBJSON 解析。问题是解析结果返回 null(在 NSDictionary 中)。我已经在 Firefox POST 工具中测试了 url,它返回了 Content-Type = application/x-www-form-urlencoded 和 Method = POST 的结果。如何在 SBJSON 文件解析中使用 Content-Type 和 Method[POST, GET]?真的,我在谷歌搜索中找不到结果(对不起)。请帮我解决我的问题。请建议我任何示例代码或想法。提前致谢。

这是我的代码,

SBJSON *jsonParser = [[SBJSON new] autorelease];
    NSURL *urls = [NSURL URLWithString:[NSString stringWithFormat:@"SAMPLE URL"]];
    NSString *stringUrl = [NSString stringWithFormat:@"%@",urls];
    NSDictionary *dictionary = (NSDictionary *) [jsonParser objectWithString:stringUrl error:nil];
    NSLog(@"Dictionary : %@", dictionary);

字典返回 null。如何在 SBJSON 文件解析中使用 Content-Type 和 [POST,GET] 方法?

提前致谢。

4

1 回答 1

0

您实际上并没有在 URL 处获取字符串数据,只是创建一个 URL 并对其进行解析,不出所料,它不能转换为 JSON 对象。您应该使用类似 NSURLConnection 或更简单的 ASIHTTP 之类的方式异步获取字符串数据,然后解析结果。

于 2011-11-10T12:21:32.207 回答