NSData转字符串
[NSString alloc] initWithData: encoding:] 模型转字典
attInfo.keyValues 字典转模型
ZTEOutputInfo *outputInfo = [ZTEOutputInfo objectWithKeyValues:responseObject]; 模型转Json字符串
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:attInfo.keyValues
options:NSJSONWritingPrettyPrinted
error:nil ];
NSString* jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding] ; 综合例子:
+ (void)checkAttatchStatus:(ZTEATTInfo *)attInfo t:(NSString *)t
success:(void (^)(NSMutableDictionary *response))success failure:(void (^)(NSError *error))failure{ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:attInfo.keyValues
options:NSJSONWritingPrettyPrinted
error:nil ];
NSString* jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding] ; ZTEInputInfo *inputInfo = [[ZTEInputInfo alloc] init];
inputInfo.C = @"SubmitMCL";
inputInfo.D = jsonString;
// CCLog(@"----D:%@",attInfo.keyValues);
ZTEFilterInfo *filterInfo = [[ZTEFilterInfo alloc] init];
filterInfo.K = @"ID";
filterInfo.V = t;
inputInfo.F = @[filterInfo]; NSString* serverip = [ZTEServerAddrMng checkMailStatusAddr2]; [kAppDelegate.netManager postPath:serverip parameters:inputInfo.keyValues
postDataEncodingType:PostDataEncodingTypeJSON
success:^(EMMHTTPRequestOperation *operation, id responseObject) {
CCLog(@"Success: %@", responseObject); ZTEOutputInfo *outputInfo = [ZTEOutputInfo objectWithKeyValues:responseObject];
CCLog(@"-------%@",outputInfo.keyValues); if ([outputInfo.S integerValue ] == 1) {
if (success) {
NSMutableDictionary *resultDict = [NSJSONSerialization JSONObjectWithData:[(NSString *)outputInfo.D dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableLeaves error:nil];
success(resultDict);
}
}else{
[ZTETipInfoView showTipWithMessage:outputInfo.M andState:KaBuTipInfoState_Failed];
} } failure:^(EMMHTTPRequestOperation *operation, NSError *error) {
CCLog(@"Error: %@", error);
[ZTETipInfoView showTipWithMessage:@"网络错误" andState:KaBuTipInfoState_Failed];
if(failure){
failure(error);
}
}]; }

JsonString,字典,模型之间相互转换的更多相关文章

  1. IOS 字典模型互转框架 MJExtension

    IOS 字典模型互转框架 MJExtension   能做什么? MJExtension是一套字典和模型之间互相转换的超轻量级框架 MJExtension能完成的功能 字典(JSON) -->  ...

  2. IRandomAccessStream, IBuffer, Stream, byte[] 之间相互转换

    /* * 用于实现 IRandomAccessStream, IBuffer, Stream, byte[] 之间相互转换的帮助类 */ using System;using System.IO;us ...

  3. iOS 字典与JSON相互转换

    iOS 字典与JSON相互转换 首先简单说一下为什么会写这种幼稚的文章. 现在的网络请求几乎都是AFN完成的,AFN也为我们写了了JSON转换字典的方法,但是不要忘记后台是一个很爱用JSON的人群,H ...

  4. 标准盒模型与IE盒模型之间的转换

    首先上图,这两张很明显可以看出IE盒模型和标准盒模型之间的差别. 当然今天不是去细细追究两种模型具体是怎么去计算布局的,那个很多文章已经已经有过了,不再重复.以前刚开始学习盒模型的时候,就学到的是IE ...

  5. WebService(2)-XML系列之Java和Xml之间相互转换

    源代码下载:链接:http://pan.baidu.com/s/1ntL1a7R password: rwp1 本文主要讲述:使用jaxb完毕对象和xml之间的转换 TestJava2xml.java ...

  6. php中 xml json 数组 之间相互转换

    php中 xml json  数组 之间相互转换 1 数组转json $result = array( 'status' =>$status, 'message'=>$message, ' ...

  7. SAP MM 销售订单库存与普通库存之间相互转换过账后对于EBEWH以及MBEWH表的更新

    SAP MM 销售订单库存与普通库存之间相互转换过账后对于EBEWH以及MBEWH表的更新 1,DEMO数据 物料号:1300009995 工厂:2160 销售订单号/item号:0010097627 ...

  8. firedac数据集和字符串之间相互转换

    firedac数据集和字符串之间相互转换 /// <author>cxg 2018-12-20</author> unit DatasetString; interface u ...

  9. python datetime和unix时间戳之间相互转换

                                python datetime和unix时间戳之间相互转换 1.代码:    import time    import datetime # ...

随机推荐

  1. SDE用户密码到期

    系统使用Arcsde for oracle 11g ,一直使用正常,突然有一天客户打电话说系统中地图不显示了.登陆GIS服务器,发现sde数据已经无法链接,错误提示:“ [ORA-28002: the ...

  2. oracle数据库中的基本语句

    下面的都是最基本的oracle数据库的数据查询语句,这是我在网上整理的一份文档,方便以后自己的查看,当然,能把这些记下来就是最好的. 说明:查询表中的数据 1. select * from emp; ...

  3. 2016-10-17: source insight插件

    使用快捷键注释,单行注释,多行注释,#if 0注释 将文件 mycomment.em点此下载放到sourceinsight的Base工程的路径下(一般是在C:\Documents and Settin ...

  4. linux 配置 tomcat 自动发布脚本

    首先将打包好的 war 包(举例 management-20160809-1.0.war),传到 tomcat 的 webapps 目录下,然后在 tomcat 目录下新建 deploy.sh 脚本. ...

  5. java学习第16天(补充可变参数)

    如果我们在写方法的时候,参数个数不明确,就应该定义可变参数. 格式: 修饰符 返回值类型 方法名(数据类型... 变量) {} 注意: A:该变量其实是一个数组名 B:如果一个方法有多个参数,并且有可 ...

  6. python中的浅拷贝和深拷贝

    1.赋值语句 a = 'abc' b = a print id(a) print id(b) # id(a):29283464 # id(b):29283464 通过简单的复制,我们可以看到,a b其 ...

  7. UE4.11新特性:胶囊体阴影

    官方介绍 虚幻引擎现在支持非常柔滑的间接阴影,由代表角色的胶囊体来进行投影. 通常,在受间接光照时,并不会产生阴影,除非是屏幕空间环境遮罩.间接投影需要做的非常柔滑,因为间接光照是来自很多不同的方向, ...

  8. EBS中后台AP发票审批脚本

    Declare    l_Hold_Count Number;    l_Funds_Code Varchar2(30);      l_Approve_Status Varchar2(120); B ...

  9. Vagrant的一个BUG - 不支持'change_host_name'

    ==> master: Setting hostname... Vagrant attempted to execute the capability 'change_host_name' on ...

  10. 实时消息平台NSQ的特性

    NSQ是GO语言开发的可用于大规模系统中的实时消息服务,但是和RabbitMQ等相比,它具有什么特色,什么场景下选择NSQ呢? NSQ的自身特色很明显,最主要的优势在如下三个方面: 1,性能.在多个著 ...