NSDictionary to jsonString 

[self DataTOjsonString:dic]

-(NSString*)DataTOjsonString:(id)object
{
NSString *jsonString = nil;
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object
options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
error:&error];
if (! jsonData) {
NSLog(@"Got an error: %@", error);
} else {
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
return jsonString;
}

NSDictionary to jsonString的更多相关文章

  1. NSDictionary to jsonString || 对象转json格式

    -(NSString*)DataTOjsonString:(id)object { NSString *jsonString = nil; NSError *error; NSData *jsonDa ...

  2. iOS不使用JSONKit做Dic到JsonString的转换

    NSDictionary to jsonString [self DataTOjsonString:dic] -(NSString*)DicToJsonString:(id)object { NSSt ...

  3. IOS一些高效的第三方框架库

    MBProgressHUD ——进展指示符库 苹果的应用程序一般都会用一种优雅的,半透明的进度显示效果,不过这个API是不公开的,因此你要是用了,很可能被清除出AppStore.而 MBProgres ...

  4. IOS 读取本地的Json/plist 文件

    一.一般本地可以存储轻量级数据存储 plist  这个主要是操作字典 方法如下: NSString * sampleFile= [[[NSBundle mainBundle] bundlePath] ...

  5. TouchJSON的简单使用

    TouchJSON是OC转换JSON的一个第三方类库,使用简单.在GitHub上可以轻松获取:TouchJSON 以下是简单的事例演示从douban movie请求JSON数据并转为字典对象后对控件赋 ...

  6. iso十款常用类库

    iso十款常用类库 MBProgressHUD(进展指示符库)   地址:https://github.com/jdg/MBProgressHUD   苹果的应用程序一般都会用一种优雅的,半透明的进度 ...

  7. iOS三方支付--微信支付/支付宝支付

    一.微信支付 1.注册账号并申请app支付功能 公司需要到微信开放品台进行申请app支付功能 , 获得appid和微信支付商户号(mch_id)和API秘钥(key) . Appsecret(secr ...

  8. XML与JSON解析

    [XML简介] XML在线校验工具: http://tool.oschina.net/codeformat/xml 可扩展标记语言(EXtensible Markup Language) 一种标记语言 ...

  9. jsonString转NSDictionary

    NSData *webData = [ \": {\"name\": \"Jerry\",\"age\": \"12\& ...

随机推荐

  1. Null modem接线

    1.6 <-> 4 2 <-> 3 3 <-> 2 4 <-> 1.6 5 <-> 5 7 <-> 8 8 <-> ...

  2. OGNL表达式(待解答)

    OGNL表达式的路径到底怎样的?下面代码看不懂为什么要这样?

  3. Apache + PHP 环境搭建

    环境: Win7 64位 php-5.6.19-Win32-VC11-x64 httpd-2.4.18-win64-VC11 下载地址: php:  http://windows.php.net/do ...

  4. mysq修改密码

    1.确定你的mysql 是否能正常工作登录数据库cmd--"命令提示字符"窗口录入,录入cd C:\mysql\bin 并按下回车键,将目录切换为 cd C:\mysql\bin再 ...

  5. [ActionScritp 3.0] 使用LocalConnection建立通信

    包 flash.net 类 public class LocalConnection 继承 LocalConnection → EventDispatcher → Object 语言版本:  Acti ...

  6. Python偏函数

    偏函数 一个带n 个参数,curried 的函数固化第一个参数为固定参数,并返回另一个带n-1 个参数函数对象 >>> from functools import partial & ...

  7. ThinkPHP 3.2.3集成uploadify上传控件

    uploadify控件有一个坑爹的问题,就是文件上传时会session丢失,官方解释http://www.uploadify.com/documentation/uploadify/using-ses ...

  8. JavaScript list 去重复

    function unique(arr) { var result = [], hash = {}; for (var i = 0, elem; (elem = arr[i]) != null; i+ ...

  9. 70. Implement strStr() 与 KMP算法

    Implement strStr() Implement strStr(). Returns a pointer to the first occurrence of needle in haysta ...

  10. 【练习】flashback基于scn的闪回查询

    1.创建表dept1: :: SCOTT@ORA11GR2>create table dept1 as select * from dept; Table created. :: SCOTT@O ...