iOS Json解析中特殊字符串('\\')处理
2020-01-10 本文已影响0人
白色天空729
需解析的JSON:
事出起因:源自公司一个接口不能解析。。。。
{"resultCode":100,"resultMessage":"查询成功","result":"{\"statu\":\"1\",\"content\":\"读取成功\",\"Meetings\":[{\"Subject\":\"优秀青年护士\\总主带教老师培训\"}]}"}
以下为一个技术群里的聊天记录截图:












看了这么多,我这边的处理就是:
将需要解析成json的字符串进行处理:
NSString *content = [[result mj_JSONString] stringByReplacingOccurrencesOfString:@"\\'" withString:@"\""];
content = [content stringByReplacingOccurrencesOfString:@"\r\n" withString:@""];
content = [content stringByReplacingOccurrencesOfString:@"\n" withString:@""];
content = [content stringByReplacingOccurrencesOfString:@"\t" withString:@""];
content = [content stringByReplacingOccurrencesOfString:@"\\" withString:@""];
反正要做好预防工作,不然后台一个不小心,咱就得背锅嘿嘿嘿(没针对后台哈~~~🙊)
类似情况的文章:
https://blog.csdn.net/u014588619/article/details/50144913
https://blog.csdn.net/fallenink/article/details/53672027
...