A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© vitanie 中级黑马   /  2015-3-2 19:06  /  594 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. /**
  2. 合成 语音json格式的消息
  3. */
  4. + (NSString *)getJsonString:(NSDictionary *)dic withDownloadURL:downloadURL
  5. {
  6. //    {"time":"3","filePath":"http:\/\/218.244.151.164:80\/leawinInterfaces\/upload\/files\/20140814171510482.amr","userid":"","from":"OUT","type":"record","date":"2014-08-14 17:15:10","receive":"发送成功","msg":"3″语音消息"}
  7.     NSMutableString *jsonStr = [[NSMutableString alloc] init];
  8.    
  9.     NSString *timeL = @"\"time\"";
  10.     NSString *timeR = [NSString stringWithFormat:@"\"%d\"", [dic[@"duration"] integerValue]];
  11.     NSString *time = [NSString stringWithFormat:@"%@:%@,", timeL, timeR];
  12.     [jsonStr appendString:time];
  13.    
  14.     NSString *filePathL = [NSString stringWithFormat:@"\"filePath\""];
  15.     NSString *filePathR = [NSString stringWithFormat:@"\"%@\"", downloadURL];
  16.     [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", filePathL, filePathR]];
  17.    
  18.     NSString *useridL = @"\"userid\"";
  19.     NSString *useridR = @"\"\"";
  20.     [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", useridL, useridR]];
  21.    
  22.     NSString *fromL = @"\"from\"";
  23.     NSString *fromR = @"\"OUT\"";
  24.     [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", fromL, fromR]];
  25.    
  26.     NSString *typeL = @"\"type\"";
  27.     NSString *typeR = @"\"record\"";
  28.     [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", typeL, typeR]];
  29.    
  30.     NSString *dateL = @"\"date\"";
  31.     NSString *dateR = [self getDataWithDownloadURL:downloadURL];
  32.     [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", dateL, dateR]];
  33.    
  34.     NSString *receiveL = @"\"receive\"";
  35.     NSString *receiveR = @"\"发送成功\"";
  36.     [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", receiveL, receiveR]];
  37.    
  38.     NSString *msgL = @"\"msg\"";
  39.     NSString *msgR = [NSString stringWithFormat:@"\"%d″语音消息\"", [dic[@"duration"] integerValue]];
  40.     [jsonStr appendString:[NSString stringWithFormat:@"%@:%@", msgL, msgR]];
  41.    
  42.     [jsonStr insertString:@"{" atIndex:0];
  43.     [jsonStr insertString:@"}" atIndex:jsonStr.length];
  44.    
  45.     return jsonStr;
  46. }
复制代码

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马