大家好我是一個新的iphone開發者。我收到了我所需的URL的響應,如下所示,我需要獲得"CategoryID":1
的名稱和"CategoryID":2
的名稱都在單獨的數組集合中。如何實現獲取iphone中的JSON對象的代碼?謝謝你得到響應 代碼:如何實現獲取iPhone中的JSON對象的代碼?
theXML = [[NSString alloc] initWithBytes: [RoutData mutableBytes] length:[RoutData length] encoding:NSUTF8StringEncoding];
NSLog(@"---->>>>>>-->>>:%@",theXML);
響應:
LocationTracking[1807:f803] ---->>>>>>-->>>:<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><getGearLockerCategoriesResponse xmlns="http://tempuri.org/"><getGearLockerCategoriesResult><status>SUCCESS</status><errorType /><errorMessage /><jsonString>[{"CategoryID":1,"ItemCount":1,"level":1,"Name":"Boots","Description":"Boots descrition","childs":[{"CategoryID":2,"ItemCount":1,"level":2,"Name":"Cold Water","Description":"Cold Water Description","childs":[]}]}]</jsonString><serverTimestamp>63477507673796</serverTimestamp></getGearLockerCategoriesResult></getGearLockerCategoriesResponse></soap:Body></soap:Envelope>
<jsonString>
[{"CategoryID":1,"ItemCount":1,"level":1,"Name":"Boots","Description":"Boots
descrition","childs":[{"CategoryID":2,"ItemCount":1,"level":2,"Name":"Cold
Water","Description":"Cold Water Description","childs":[]}]}]
</jsonString>
<serverTimestamp>63477390375625</serverTimestamp>
</DiveTravelerResponse>
獲取NSMutableDictionary中的所有數據,然後設置條件。然後在條件基礎上添加NSMutableArray然後從數組中獲取值。 – Ayaz 2012-07-09 06:17:04