xcode JSONKIt 序列化 NSDictionary
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7116749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JSONKIt serialize NSDIctionary
提问by Oksana
How to use JSONKit to serialize a NSDictionary into string? I couldn't find any examples.
如何使用 JSONKit 将 NSDictionary 序列化为字符串?我找不到任何例子。
回答by Chris Doble
The "Serializing Interface" section of the JSONKit READMEstates that the library adds a method JSONString
to NSArray
, NSDictionary
, and NSString
. This looks like what you're after.
所述的“序列化界面”部分JSONKit自述指出该库增加了一个方法JSONString
来NSArray
,NSDictionary
和NSString
。这看起来像你所追求的。
NSDictionary *dictionary = [NSDictionary withObjectsAndKeys:...];
NSString *JSON = [dictionary JSONString];