- /**
- 合成 语音json格式的消息
- */
- + (NSString *)getJsonString:(NSDictionary *)dic withDownloadURL:downloadURL
- {
- // {"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″语音消息"}
- NSMutableString *jsonStr = [[NSMutableString alloc] init];
-
- NSString *timeL = @"\"time\"";
- NSString *timeR = [NSString stringWithFormat:@"\"%d\"", [dic[@"duration"] integerValue]];
- NSString *time = [NSString stringWithFormat:@"%@:%@,", timeL, timeR];
- [jsonStr appendString:time];
-
- NSString *filePathL = [NSString stringWithFormat:@"\"filePath\""];
- NSString *filePathR = [NSString stringWithFormat:@"\"%@\"", downloadURL];
- [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", filePathL, filePathR]];
-
- NSString *useridL = @"\"userid\"";
- NSString *useridR = @"\"\"";
- [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", useridL, useridR]];
-
- NSString *fromL = @"\"from\"";
- NSString *fromR = @"\"OUT\"";
- [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", fromL, fromR]];
-
- NSString *typeL = @"\"type\"";
- NSString *typeR = @"\"record\"";
- [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", typeL, typeR]];
-
- NSString *dateL = @"\"date\"";
- NSString *dateR = [self getDataWithDownloadURL:downloadURL];
- [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", dateL, dateR]];
-
- NSString *receiveL = @"\"receive\"";
- NSString *receiveR = @"\"发送成功\"";
- [jsonStr appendString:[NSString stringWithFormat:@"%@:%@,", receiveL, receiveR]];
-
- NSString *msgL = @"\"msg\"";
- NSString *msgR = [NSString stringWithFormat:@"\"%d″语音消息\"", [dic[@"duration"] integerValue]];
- [jsonStr appendString:[NSString stringWithFormat:@"%@:%@", msgL, msgR]];
-
- [jsonStr insertString:@"{" atIndex:0];
- [jsonStr insertString:@"}" atIndex:jsonStr.length];
-
- return jsonStr;
- }
复制代码
|
|