在利用json-framework来实现json解析的过程时,会出现"-JSONValue Failed. Error is : Unescaped control character"的错误。这种问题一般是由转义字符引起的,这些转义字符可能是因为web服务编写时造成的,也可能是其它原因导致的。。

NSString *jsonString0 = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"File.text" ofType:nil] encoding:NSUTF8StringEncoding error:nil];
    
    NSLog(@"%@",jsonString0);

  //添加过滤
    NSString *jsonString = [jsonString0 stringByReplacingOccurrencesOfString:@"\r" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\t" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\v" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\f" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\b" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\a" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\e" withString:@""];
    
    NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    
    NSError *error = nil;
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
    
    NSLog(@"%@",error);
    
    NSLog(@"%@",dict);

Json解析报错: Error is : Unescaped control character...的解决方法的更多相关文章

  1. gcc编译的时候报错 error trying to exec 'cc1plus': execvp 解决方法

    sudo apt install --reinstall build-essential -y

  2. 解压tar.gz文件报错gzip: stdin: not in gzip format解决方法

    解压tar.gz文件报错gzip: stdin: not in gzip format解决方法 在解压tar.gz文件的时候报错 1 2 3 4 5 [Sun@localhost Downloads] ...

  3. oracle 11g R2安装报错ORA-00604及ORA-06553的原因及解决方法

    10月31日PO主打算装oracle 11g R2,于是通过QQ旋风离线下载功能从oracle官网的链接下载了win32_11gR2_database_1of2.zip和win32_11gR2_dat ...

  4. oauth2(spring security)报错method_not_allowed(Request method 'GET' not supported)解决方法

    报错信息 <MethodNotAllowed> <error>method_not_allowed</error> <error_description> ...

  5. ***XAMPP:报错 Unable to load dynamic library的解决方法

    A PHP Error was encountered Severity: Core Warning Message: PHP Startup: Unable to load dynamic libr ...

  6. 【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法

    很多开发者在接入华为帐号服务时,经常会出现907135701的报错.根据官网文档说明,错误码907135701表示: 这个错误码在安卓和鸿蒙上都会出现,导致该报错的原因有很多,开发者可以按照下面几点进 ...

  7. Openwrt 编译报错:rootfs image is too big解决方法

    修改: tools/firmware-utils/src/mktplinkfw2.c static struct flash_layout layouts[] = { { .id = "8M ...

  8. PHP加密3DES报错 Call to undefined function: mcrypt_module_open() 的解决方法

    我也是PHP新手,通过w3cschool了解了一下php基本原理之后就开写了.但仍是菜鸟. 先不管3DES加密的方法对不对,方法都是网上的,在运行的时候报了个错,把小弟整死了.找来找去终于自己摸出了方 ...

  9. scp报错:not a regular file,解决方法:加参数 -r

    命令:scp  -P1234  /data/aa   root@192.0.0..0:/data 文件结构:/data/aa/yearmonth=2015-09 报错:not a regular fi ...

随机推荐

  1. 套接字之select系统调用

    select是IO多路复用的一种方式,用来等待一个列表中的多个描述符的可读可写状态: SYSCALL_DEFINE5(select, int, n, fd_set __user *, inp, fd_ ...

  2. spark 笔记 14: spark中的delay scheduling实现

    延迟调度算法的实现是在TaskSetManager类中的,它通过将task存放在四个不同级别的hash表里,当有可用的资源时,resourceOffer函数的参数之一(maxLocality)就是这些 ...

  3. spring boot统一异常页面

    只需要创建一个类就可以了 package com.ulic.gis.securityManage.controller; import java.util.Map; import javax.serv ...

  4. 4. 获取当前的文件夹的路径,以及当前文件名的路径 os.path.realpath

    使用os.path.realpath(__file__) 获得当前的文件夹的路径名, 使用os.path.split 进行路径切割 import os src, _= os.path.split(os ...

  5. 全面解读php-网络协议

    一.OSI七层模型 1.物理层 作用:建立,维护,断开物理连接 2.数据链路层 作用:建立逻辑连接,进行硬件地址寻址,差错校验等功能. 3.网络层 作用:进行逻辑地址寻址,实现不同网络之间的路径选择. ...

  6. C# hook WndProc

    在当前窗口里重载WndProc,只能捕获到当前WinForm窗口的消息 protected override void WndProc(ref Message m) { if (m.Msg == WM ...

  7. leetcode 34在排序数组中查找元素的第一个和最后一个位置

    class Solution { public: vector<int> searchRange(vector<int>& nums, int target) { ve ...

  8. 自定义配置文件读取产生的“无法添加已属于该配置的 ConfigurationSection”异常解决办法

    最近在编写一个读写自定义配置文件的功能时遇到一个问题,在初始化的时候读入配置显示出来,修改后把配置回存到配置文件,在回存的时候,先移除配置节,再添加,在添加的时候遇到如下的异常: {"无法添 ...

  9. The window object

    At the core of the BOM is the window object, which represents an instance of the browser. The window ...

  10. Dojo入门:dojo中的事件处理

      JS为DOM添加事件 在原生的环境下,为DOM添加事件处理函数有多种方法: <input type="button" name="btn" value ...