I have a Rest Response like this
{
"data": [
{
"id": "adhoc_Expense_process:1:43",
"key": "adhoc_Expense_process",
"name": "Expense process",
"version": 1,
"deploymentId": "10",
"resourceName": "org\/activiti\/examples\/adhoc\/Expense_process.bpmn20.xml",
"diagramResourceName": "org\/activiti\/examples\/adhoc\/Expense_process.png",
"startFormResourceKey": null,
"graphicNotationDefined": "true"
},
{.
.
.
},
]
}
I am handling the response like this.
- (void)request:(RKRequest*)request didLoadResponse:(RKResponse*)response {
if ([request isGET]) {
// Handling GET /foo.xml
if ([response isOK]) {
// Success! Let's take a look at the data
NSLog(@"Retrieved XML: %@", [response bodyAsString]);
NSString *str = [response bodyAsString];
NSDictionary *json = [str JSONValue];
// Get all object
NSArray *items = [json valueForKeyPath:@"data"];
NSEnumerator *enumerator = [items objectEnumerator];
NSDictionary* item;
while (item = (NSDictionary*)[enumerator nextObject]) {
NSLog(@"clientId = %@", [item objectForKey:@"id"]);
NSLog(@"clientName = %@",[item objectForKey:@"key"]);
NSLog(@"job = %@", [item objectForKey:@"version"]);
}
}
}
When i log the response with bodyAsString i can see the proper xml response on the console.But i am unable to parse it.I am using SBJSON.h or in other words the SBJSON framework.
Do you see anything wrong in the way i am parsing it.The error messages are like this..
2011-11-29 17:09:53.601 Views[6166:fb03] -[__NSCFString JSONValue]: unrecognized selector sent to instance 0x71c9200
2011-11-29 17:09:53.602 Views[6166:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString JSONValue]: unrecognized selector sent to instance 0x71c9200'
I added the following in BuildPhases settings of the project.
sbjson-ios in “target dependencies”
libsbjson-ios.a in “link binary with libraries”.
I realised i added some such ones when i added the restkit framework.
Thanks guys,it helped.
Anusha