通过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 的值?
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:
You can try RestKit