宽容他人,放过自己。

创建json串

Posted on By anchoriteFili

// 创建json串
- (NSString *)createJsonString {
    NSString *jsonString = @"";
    
    NSDictionary *dict = @{
                           @"voiceurl":_voiceurl,
                           @"message":_message,
                           @"username":_username,
                           @"photo":_photo,
                           @"time":_time,
                           @"userid":[NSNumber numberWithInteger:_userid],
                           @"messagetype":[NSNumber numberWithInteger:_messagetype],
                           @"voicetime":[NSNumber numberWithInteger:_voicetime],
                           @"isread":[NSNumber numberWithInteger:_isread],
                           };
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:nil];
    jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    return jsonString;
}