我是JSON的新手,刚开始围绕它的功能进行包装。JSON GET或POST的返回值应该是什么样子?
我想看看我是否可以从某些JSON方法打印一些数据。我一直在第一个和第二个之间交替。这些想法是,看看我能得到什么打印:
id newConnection = [scAPI performMethod:@"GET" onResource:@"me/connections.json" withParameters:nil context:nil userInfo:nil];
// id newConnection = [scAPI performMethod:@"POST"
// onResource:@"connections"
// withParameters:[NSDictionary dictionaryWithObjectsAndKeys:
// @"facebook_profile", @"service",
// @"imc://connection", @"redirect_uri",
// @"touch", @"display", //optional, forces services to use the mobile auth page if available
// nil]
// context:nil
// userInfo:nil];
NSLog(@"newConnection %@", newConnection);
NSLog(@"Is of type: %@", [newConnection class]);
NSDictionary *dict = [newConnection objectFromJSONString];
for (id key in dict) {
NSLog(@"key: %@, value: %@", key, [dict objectForKey:key]);
}
上面的代码不犯错,我得到日志如:
这是否正确?如何正确使用这些JSON方法来获取值的字典?
编辑1
要清楚我使用JSONKit :)
要写字典记录你可以简单地使用'NSLog(@“%@”,dict);'。你的字典似乎是空的,虽然(或n),因为没有“key .. value ..”在日志 –
@babbidi中显示。究竟。任何想法为什么? –