iOS对象(字典或数组)转化为JSon字符串
2024-08-26 23:09:45
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[dictionary setValue:@"hello" forKey:@"one"];
[dictionary setValue:@"world" forKey:@"two"];
NSArray *arry=[NSArray arrayWithObjects:@"001",@"002",@"003", nil];
[dictionary setValue:arry forKey:@"three"];
NSData *data=[NSJSONSerialization dataWithJSONObject:dictionary options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonStr=[[NSString alloc]initWithData:dataencoding:NSUTF8StringEncoding];
NSLog(@"jsonStr==%@",jsonStr);
输出结果为:
str=={
"one" : "hello",
"two" : "world",
"three" : [
"001",
"002",
"003"
]
}
最新文章
- 修复百度编辑器(UM)禁用时上传图片按钮还可点击的BUG;
- Web Components是不是Web的未来
- Doctrine2 SQL语句
- windows内核编程之常用数据结构
- [转载]Android 编译环境 build/envsetup.sh分析
- css选择器权值
- 在ubuntu上搭建reviewboard
- mysql_upgrade命令
- TYPE C PD测试板 UFP测试板
- Sequence《优先队列》
- delphi 发送Windwos消息控制按钮(控制计算器里的某一个按钮)
- /system改成可写
- python_嵌套列表变成普通列表
- react-native-image-picker 运用launchCamera直接调取摄像头的缺陷及修复
- org.apache.catalina.core.StandardContext.startInternal Context [/test] startup failed due to previou
- [译]Ocelot - Claims Transformation
- jqueryd的post传递表单以及取消表单的默认传递
- for...else 小记
- POJ 1200 Crazy Search (哈希)
- docker+jenkins实现spring boot项目持续集成自动化部署
热门文章
- [转]在Storyboard中使用自定义的segue类型
- [SaltStack] salt-minion启动流程
- C#性能优化篇 - 基于索引器封装EPList
- Codeforces 最大流 费用流
- Codeforces 323C Two permutations
- dedecms调用文章发布日期
- 处理类型(typedef,uisng,auto,decltype)
- MFC中 创建基于CFormView的文档视图程序
- 自学MVC看这里——全网最全ASP.NET MVC 教程汇总【转】
- Windows下ELK-5.4.3环境搭建