1.\0 导致JSON无法解析的问题,把\0替换成@""即可。

1     NSString *string = @"{\n\t\"responseType\":\t-1\n}\0";
2     NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
3     
4     NSError *error = nil;
5     NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
6     
7     NSLog(@"%@, %@", dictionary, error);

输出结果:2016-04-26 11:17:58.460 ******[1635:96721] (null), Error Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." UserInfo={NSDebugDescription=Garbage at end.}

相关文章:

  • 2022-12-23
  • 2021-10-22
  • 2022-02-24
  • 2021-10-19
  • 2021-12-04
  • 2021-11-28
  • 2018-09-01
猜你喜欢
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 1970-01-01
  • 2021-05-14
  • 2021-09-13
相关资源
相似解决方案