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. .vimrc vim 配置大全

    map <F9> :call SaveInputData()<CR>func! SaveInputData() exec "tabnew" exec 'no ...

  2. 关于Jquery中ajax介绍

    jQuery 底层 AJAX 实现.简单易用的高层实现见 $.get, $.post 等.$.ajax() 返回其创建的 XMLHttpRequest 对象.大多数情况下你无需直接操作该函数,除非你需 ...

  3. Cacti:添加监控磁盘IO

    来自:http://blog.sina.com.cn/s/blog_61c07ac50101gkzp.html 1.检查net-snmp是否支持IO监控 snmpwalk -v 1 -c public ...

  4. bashrc

    # ~/.bashrc: executed by bash(1) for non-login shells.# see /usr/share/doc/bash/examples/startup-fil ...

  5. Spring异常抛出触发事务回滚

    Spring.EJB的声明式事务默认情况下都是在抛出unchecked exception后才会触发事务的回滚 /** * 如果在spring事务配置中不为切入点(如这里的切入点可以定义成test*) ...

  6. java8之接口增强

    Java8是由oracle公司于2014年3月正式发布,它是继java5 以来最重要的发布版本.Java8包含了很多新的特性,可以简化开发,提升代码的可读性. Java8的一些重要新特性包括: l 接 ...

  7. [JS]递归对象或数组

    function recursive(obj) { var output = ''; if (typeof obj === 'object') { for (var key in obj) { var ...

  8. asp.net core获取自定义json的配置内容

    首先在主目录下建立:Iyibank.Web.json文件 里边的内容如下: { "ConnectionStrings": { "RedisCache": &qu ...

  9. highCharts的多图导出

    已实现HighChart的多图导出,不能上传文件,所以需要call我735734485.

  10. mysql 用source 导入数据库报错

    平时一直使用phpmyadmin或mysqldum进行导出,使用source命令导入数据库. 但换了新版本mysql后,上述导入方法出现以下错误: ERROR: Unknown command '\\ ...