我是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中顯示。究竟。任何想法爲什麼? –