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. sass安装与使用

    安装: 1.安装ruby 2.安装Koala,用于sass编译 3.gem install sass(mac电脑安装如果安装报错,一般是权限问题,没有权限安装到ruby下面,因此可以尝试sudo ge ...

  2. 这些年正Android - 母亲

    记得小时候,在自己写完一篇作文,完成母亲布置的任务后,就会搬走母亲正在使用的大椅子,面朝门前的马路,就这么憧憬的坐着,听着母亲给小孩打针时,小孩哇哇的哭声,努力的幻想着自己以后能做一个顶天立地的男子汉 ...

  3. 答:SQLServer DBA 三十问之二:系统DB有哪些,都有什么作用,需不需要做备份,为什么;损坏了如何做还原(主要是master库)

    2. 系统DB有哪些,都有什么作用,需不需要做备份,为什么:损坏了如何做还原(主要是master库): master:它包含一个系统表集合,是整个实例的中央存储库,维护登录账户,其他数据库,文件分布, ...

  4. python学习:环境搭建

    1.图解eclipse环境下安装python3.x插件支持:http://www.tuicool.com/articles/M3Afyu 其中如果 然后,选择Add按钮,Name:Python3,Lo ...

  5. android入门:第一天

    android是什么? 是一个基于linux开源的操作系统,主要适用于智能设备,如智能手机,平板,智能电视,智能手表,谷歌眼镜,智能家居,由google开发,2008年开发出第一个版本 android ...

  6. iframe跨域cookie问题

    今天在项目里面遇到了iframe跨域不能写cookie的问题.应用场景是这样的:有A和B两个业务,A要通过iframe的方式嵌入B,但是在ie下A不能通过写cookie的方式记录信息,在firefox ...

  7. golang 前置补0

    package main import ( "fmt" ) func main() { a := 1 fmt.Println(a) //前置补0 fmt.Printf(" ...

  8. python使用代理ip发送http请求

    一.需求背景 网站刷票时,经常会遇到限制一个ip只能投票一次的限制,为此需要使用代理ip 二.脚本如下: 1.Proxy_http.py使用代理ip发送httpr的get和post请求 #coding ...

  9. ActiveX: 如何用.inf和.ocx文件生成cab文件

    ActiveX: 如何用.inf和.ocx文件生成cab文件  

  10. PHP实现异步调用方法研究

    作者: Laruence 本文地址: http://www.laruence.com/2008/04/14/318.html 转载请注明出处 , ,); curl_setopt_array(, ); ...