I've got an OData service that can return JSON values for an object collection. I'd like to point an iPhone app at a collection of JSON objects off of that service (results shown below with one sample record).
How can I parse these nested values? When I convert the response string to JSON values, it only grabs "d" (my code for that is also below).
{
"d" : {
"results": [
{
"__metadata": {
"uri": "http://someserver/service.svc/collection(1234L)", "type": "My.Namespace.Type"
}, "Property1": "value1", "Property2": 7274, "Collection1": {
"__deferred": {
"Property3": "http://someserver/service.svc/collection(1234L)/Images"
}
}
},
...
Sample objective C code:
- (void)requestFinished:(ASIHTTPRequest *)request
{
if (request.responseStatusCode == 200)
{
NSString *responseString = [request responseString];
textView.text = responseString;
NSDictionary *responseDict = [responseString JSONValue];
NSArray *keys = [responseDict allKeys];
[self printArray:keys]; // This prints "d"
...
}
}