美文网首页
iOS json字符串转字典

iOS json字符串转字典

作者: tongyuling | 来源:发表于2019-10-29 21:50 被阅读0次
    一、先去掉转移‘/’
                NSMutableString *responseString = [NSMutableString stringWithString:@"xxxxxxx"];
                NSString *character = nil;
                 for (int i = 0; i < responseString.length; i ++) {
                     character = [responseString substringWithRange:NSMakeRange(i, 1)];
                     if ([character isEqualToString:@"\\"])
                        [responseString deleteCharactersInRange:NSMakeRange(i, 1)];
                 }
    
    二、转字典
                NSData *jsonData = [responseString dataUsingEncoding:NSUTF8StringEncoding];
                NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];
    

    相关文章

      网友评论

          本文标题:iOS json字符串转字典

          本文链接:https://www.haomeiwen.com/subject/kacnvctx.html