starwar2012 2013-02-03 01:59 采纳率: 0%
浏览 4714
已采纳

AFNetworking没有得到正确的JSON值

我建立了一个AFNetworking HTTP Client 子类,并且注册了HTTP操作为AFJSONRequestOperation 设置默认标题:

[self setDefaultHeader:@"Content-Type" value:@"application/json"];
    [self setDefaultHeader:@"Accept" value:@"text/html"];

调用服务器:

     [[TheAPIClient sharedClient] getPath:domain parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) {

        NSLog(@"%@", JSON);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

NSLog(@"FAILED"); 

但是得到的结果是一堆数字:

<7b0d0a20 20224d65 6e755365 74223a20 7b0d0a20 20202022 4b617465 676f7269 53657422 3a205b0d 0a202020 2020207b 0d0a2020 20202020 20202245 6c656d65 6e745365 74223a20 5b0d0a20 20202020 20202020 207b0d0a 20202020 20202020 20202020 22496422 3a20312c 0d0a2020 20202020 20202020 2020224e 61766e22 3a202252 656a6520 636f636b 7461696c 222c0d0a 20202020 20202020 20202020 22426573 6b726976 656c7365 223a2022 52656a65 723f222c 0d0a2020 20202020 20202020 20202250 72697322 3a203134 392c0d0a 20202020 20202020 20202020 224b6174 65676f72 69536574 4964223a 20310d0a 20202020 20202020 20207d0d 0a202020 20202020 205d2c0d 0a202020 20202020 20224964 223a2031 2c0d0a20 20202020 20202022 4e61766e 223a2022 466f7272 6574222c 0d0a2020 20202020 20202245 6c656d65 6e745365 74496422 3a20312c 0d0a2020 20202020 2020224d 656e755f 4964223a >
}];

这是怎么回事?应该怎么解决?谢谢

  • 写回答

1条回答

  • systemsas 2013-10-31 10:35
    关注

    NSString *responseString = [[NSString alloc] initWithData: JSON encoding:NSUTF8StringEncoding];

    NSDictionary *weatherDic = [NSJSONSerialization JSONObjectWithData: JSON options:NSJSONReadingMutableLeaves error:&error];

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?