2014-04-14 62 views
-2

如何用Json響應創建NSDictionary而無需手動爲鍵添加對象?json的NSDictionary

+0

嘿,你可以定義一個更遠一點,你想要一個NSDictionary從JSON或轉換和NSDictionary到JSON? – Cocoadelica

回答

1

是的,你可以。

NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; 

here

0

您需要使用NSJSONSerialization。看一看here

請注意,將接收到的JSON對象解析爲Obj-C對象可能導致數組或字典取決於JSOn的格式。您可以使用isKindOfClass:方法進行測試。