zoukankan      html  css  js  c++  java
  • iOS json解析中包含“ ”等解析出错

    文题算是解决了,把特殊字符替换一下:
    -(NSString *)JSONString:(NSString *)aString {
        NSMutableString *s = [NSMutableString stringWithString:aString];
        //[s replaceOccurrencesOfString:@""" withString:@"\"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [s length])];
        //[s replaceOccurrencesOfString:@"/" withString:@"\/" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [s length])];
        [s replaceOccurrencesOfString:@" " withString:@"\n" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [s length])];
        [s replaceOccurrencesOfString:@"" withString:@"\b" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [s length])];
        [s replaceOccurrencesOfString:@"f" withString:@"\f" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [s length])];
        [s replaceOccurrencesOfString:@" " withString:@"\r" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [s length])];
        [s replaceOccurrencesOfString:@" " withString:@"\t" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [s length])];
        return [NSString stringWithString:s];
    }

  • 相关阅读:
    ECMAScript 2016(ES7) 知多少
    PyCharm连接远程服务器
    PyCharm远程开发和调试
    SecureCRT使用帮助
    NLP文本相似度
    程序控制结构--案例
    程序控制结构--选择结构
    程序控制结构--条件表达式
    Python序列结构--集合
    Python序列结构--字典
  • 原文地址:https://www.cnblogs.com/lihaibo-Leao/p/3597837.html
Copyright © 2011-2022 走看看