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. Android自动化学习笔记:编写MonkeyRunner脚本的几种方式

    ---------------------------------------------------------------------------------------------------- ...

  2. js+html5 +devexpress属性总结

    //获取某行某列的值 onSelectionChanged: function (selectedItems) { var data = selectedItems.selectedRowsData[ ...

  3. JavaScript笔记:对象及数组

    一.对象 在javascript中,对象是拥有属性和方法的一种基本数据类型 1.创建object 创建object实例有如下两种方式: 使用new操作符后跟object构造函数创建,如下代码: var ...

  4. Linux Top 命令解析 比较详细

    [尊重原创文章出自:http://www.jb51.net/LINUXjishu/34604.html] TOP是一个动态显示过程,即可以通过用户按键来不断刷新当前状态.如果在前台执行该命令,它将独占 ...

  5. IP转换hash以及返回

    InetAddress address = InetAddress.getByName("127.0.0.1"); System.out.println(address); int ...

  6. Centos下安装Mongodb

    转自:http://nnzhp.cn/article/10/ Mongodb是一种nosql类型的数据库,高性能.易部署.易使用的特点在IT行业非常流行. 下面介绍一下mongodb的安装方式,这里我 ...

  7. highcharts 柱状图 动态加载

    highcharts柱状图动态加载 (1):导入样式 <script type="text/javascript" src="<%=request.getCo ...

  8. 解决Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization.

    一.问题描述 OS:centos 原因是拷贝虚拟机造成的. 使用vmworkstation打开虚拟机的时候,要选择copy而非move. 二.解决描述 网络上解决步骤各异,其实就一句话.只要保证vmw ...

  9. pascal闪电入门系列目录

    第一章  准备工作 第二章  Hello,world! 第三章  输出.输入 第四章  变量常量.基本数据类型 第五章  格式.注释 第六章  运算符.表达式.优先级 第七章  分支结构 第八章  数 ...

  10. {Reship}{KMP字符串匹配}

    关于KMP字符串匹配的介绍和归纳,作者的思路非常清晰,推荐看一下 http://blog.csdn.net/v_july_v/article/details/7041827