ios - AFN返回的数据中其中一个是数组,如何取到数组中的值?
高洛峰
高洛峰 2017-04-17 17:41:27
0
4
353

通过AFN获取的返回值responseObject 如下:

{
    COCAudit = 1;
    COCHeadPicture = "COCHeadPicture13.jpg";
    COCId = 2;
    COCLevel = 11;
    COCPlateNumber = "\U9c81ayyuhg";
    COCTailPicture = "COCTailPicture13.jpg";
    COCXSZPicture = "COCXSZPicture13.jpg";
    COId = 13;
    carGIS =     (
                {
            CGId = 2;
            CGZF = 0;
            COMMCODE = 15150001;
            resultSign = true;
        }
    );
    resultSign = true;
}

求问如何取 carGIS 数组 中的 CGZF 的值?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(4)
伊谢尔伦

First, you need to learn the structure of JSON data. It has been briefly explained on the first floor.
Secondly, when parsing JSON, the value of the key is a string, which is received using NSString, an array using NSArray, and a dictionary using NSDictionary.
If value is an array or dictionary, you need to perform another value operation until you get the string position.

伊谢尔伦

You'd better learn about json, including how to write a json data.
The corresponding key=value format in json
carGIS corresponds to an array array
array is an map(dictionary)

黄舟

First of all, all the data returned is an NSDictionary object, in which carGIS is an array, and NSArray is used to receive and save it. Each element in the array is an NSDictionary object, which can be retrieved using the key value. In this question, the key value is CGZF.
The following code is just a processing step for reference only:

 carGIS = responseObject[@"carGIS"];   //取出数组
 for (NSDictionary *dic in carGIS ) {
    CGId = dic[@"CGId"];
 }
迷茫

You can try RestKit

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template