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); } }]; }