我仍在學習JSON,並使用SBJSON。我怎麼會去考慮一個NSDictionary並將其轉換成JSON對象類似:如何將NSDictionary轉換爲JSON對象?
{"id":"123","list":"456","done":1,"done_date":1305016383}
我仍在學習JSON,並使用SBJSON。我怎麼會去考慮一個NSDictionary並將其轉換成JSON對象類似:如何將NSDictionary轉換爲JSON對象?
{"id":"123","list":"456","done":1,"done_date":1305016383}
使用SBJSON增加的NSDictionary類別:
NSString *jsonString = [dictionary JSONRepresentation];
僅舉適當的鍵和值字典和SBJSON會爲你做
工作對於那些正在使用的,而不是SBJSON JSONKit:
JSONKit還提供了NS的類別字典
NSString *jsonString = [dictionary JSONStringWithOptions:JKSerializeOptionNone error:nil]
有一個JSON-API(因爲iOS5的和OS X 10.7)在官方的iOS-SDK,它被稱爲:
+ (NSData *)dataWithJSONObject:(id)obj
options:(NSJSONWritingOptions)opt
error:(NSError **)error
見Guillaume的職位詳細信息如何使用它:https://stackoverflow.com/a/9020923/261588
工程就像一個魅力。
鏈接只有答案不是很有幫助。 – Abizern