澳门新葡亰娱乐在线非标准JSON深入分析

2019-11-26 16:45 来源:未知

AFNetworking

  1. String category = "{'v-soft-list':[{typecode:'zhuanbi',gametype:'赚币',count:5},{typecode:'dongzuo',gametype:'动作',count:12},{typecode:'maoxian',gametype:'冒险',count:14},{typecode:'xiuxian',gametype:'休闲',count:61},{typecode:'zhili',gametype:'智力',count:17},{typecode:'gaoxiao',gametype:'搞笑',count:6},{typecode:'celue',gametype:'策略',count:4},{typecode:'qipai',gametype:'棋牌',count:2}]}";  
  2.           
  3.         JSONObject jsonObject = JSONObject.fromObject(category);    
  4.         JSONArray jsArray = jsonObject.getJSONArray("v-soft-list");    
  5.         for(int i=0;i<jsArray.size();i++){    
  6.            JSONObject jsObject = (JSONObject)jsArray.get(i);    
  7.            String typeCode = (String)jsObject.get("typecode");    
  8.            System.out.println(typeCode);    
  9.         }   

设置info.plist

App Transport Security Settings
Allow Arbitrary Loads

首先如果请求的数据不是Json就要设置自己请求

// 自己处理返回结果
self.manager.responseSerializer = [AFHTTPResponseSerializer serializer];


    [self.manager GET:@"http://www.changninglm.sh.cn/interface/serviceInfo.php" parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {

    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

    }];
TAG标签:
版权声明:本文由澳门新葡亰娱乐在线发布于葡亰_棋牌,转载请注明出处:澳门新葡亰娱乐在线非标准JSON深入分析