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. 期待许久的事情终于发生-微软收购Xamarin

    刚在VS推送的新闻中看到了醒目的标题:Microsoft to acquire Xamarin and empower more developers to build apps on any dev ...

  2. Python学习二(生成器和八皇后算法)

    看书看到迭代器和生成器了,一般的使用是没什么问题的,不过很多时候并不能用的很习惯 书中例举了经典的八皇后问题,作为一个程序员怎么能够放过做题的机会呢,于是乎先自己来一遍,于是有了下面这个ugly的代码 ...

  3. Mariadb 在centos 7下的安装配置

    安装Mariadb数据库: sudo yum install mariadb-server 启动数据库: sudo systemctl start mariadb 设置自动启动: sudo syste ...

  4. (分享)FreeVideo1.6.1 VIP视频播放器(支持下载)

    软件名字:FreeVideo 版 本 号 :v 1.6.1 开发语言:易语言 压缩加壳:VMP 3.0 beta 皮      肤:易简约定制版(白色) 模块使用:乐易.精易.皮肤 主要技术:其实没啥 ...

  5. The source attachment does not contain the source for the file  ActionSupport.class 错误

    报错  Syntax error, insert ";" to complete FieldDeclaration 报错   The source attachment does ...

  6. c++ 类的静态变量

    类的静态变量作为类的一部分,但不由类的创建产生,类的销毁而消失.静态变量和全局变量一样,会在main函数结束后销毁. 类可以对静态变量的值进行改变 #pragma once class ctest { ...

  7. SqlServer Where后面Case When语句的写法

    select * from tb where (case when col='***' then '***' else '***' end)='***'

  8. html尖角提示框的实现

    <style type="text/css">        .box {            background-color: #bebf22;          ...

  9. NodeJs 连接mysql一例。

    var mysql = require('mysql'); var connection = mysql.createConnection({ host :'127.0.0.1', user :'ro ...

  10. androidstudio 配置git和github

    git是版本控制工具 github是一个网站,git可以把项目上传至这个网站 1:先下载git,并且安装,一般默认即可,安装成功可以点击电脑右键出现 2:生成id_rsa.pub, 配置账号和邮箱 点 ...