0

こんにちは、私は新しい iPhone 開発者です。以下に示すように、必要な URL から応答を取得しています。"CategoryID":1名前と"CategoryID":2両方の名前を別々の配列セットに取得する必要があります。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> 
4

2 に答える 2

0

Touch JSON ライブラリは優れたソリューションです: https://github.com/TouchCode/TouchJSON

于 2012-07-09T06:18:16.100 に答える
0

NSJSONSerialization. JSON が「str」という名前の NSString にある場合:

NSError *jsonError = nil;
NSArray *rootObjectArray = [NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&jsonError];
if (rootObjectArray)
{
   /* you have a foundation object */
}
else
{
   /* something went wrong */
   NSLog(@"jsonError: %@", [jsonError localizedDescription]);
}
于 2012-07-09T06:21:16.923 に答える