iOS 字典与字符串的相互转换
来源:互联网 发布:java跨域上传图片 编辑:程序博客网 时间:2024/05/16 17:20
<pre name="code" class="objc"><span style="font-family: Arial, Helvetica, sans-serif;">//字符串转字典+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString {</span>
if (jsonString == nil) {return nil;}NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];NSError *err;NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonDataoptions:NSJSONReadingMutableContainerserror:&err];if(err) {NSLog(@"json解析失败:%@",err);return nil;}return dic;}
//字典转字符串+ (NSString*)dictionaryToJson:(NSDictionary *)dic{NSError *parseError = nil;NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];}
0 0
- iOS 字典与字符串的相互转换
- iOS 中字典与json格式的相互转换
- 字典与Json字符串相互转换
- 字典对象与Json字符串相互转换
- ios 时间与字符串相互转换,包含时区的转换
- iOS中字符串时间与时间戳的相互转换
- iOS中数组与字符串的相互转换
- python json字符串与字典对象相互转换
- NSJSONSerialization使用——json格式字符串与dict字典的相互转换
- iOS十六进制和字符串的相互转换
- iOS中OC字符串与C语言字符串之间的相互转换
- python字符串、列表、字典相互转换
- JAVA的整型与字符串相互转换
- 十六进制与字符串的相互转换
- 字符串与数值之间的相互转换
- 字符串与数值相互转换的函数
- XML与字符串的相互转换
- JAVA的整型与字符串相互转换
- eXtremeDB compiling error based on vxworks ppcgnu
- warning: could not load any Objective-C class information. This will significantly reduce the qualit
- linux与windows下文件转换
- 有关冲突域的定义
- 动态添加一个布局
- iOS 字典与字符串的相互转换
- 【模板】splay
- iOS Tabbar和Naviagtion
- TestDisk使用教程
- JFinal学习(一)
- solution Of Pat 1110. Complete Binary Tree (25)
- 在用信鸽推送JPUSH2.1.0的时候报错
- Ubuntu平台融合(Convergence)演进
- Erlang supervisor规格的dynamic行为分析