Fetch back a JSON record JSON:
{
content : [
{ action : "eat ice-cream", username : "tom" },
{ action : "play sport", username : "mike" },
{ action : "dancing", username : "dan" }
],
message : "OK",
status : 1
}
Iphone:
The Object would contain an action and username field.
In the callback function
-(void) fetchdatacompleted:(NSDictionary*)dict
{
if([dict objectForKey:@"content"] != nil)
{
[objectArray removeAllObjects];
if([[dict objectForKey:@"content"] isKindOfClass:[NSArray class]])
{
NSArray *array = (NSArray *)[dict objectForKey:@"content"];
for (NSDictionary *dict in array)
{
myobject = [[Object alloc] initWithDict:dict];
[objectArray addObject:myobject];
}
}
}
}
How does Android handle the above processing?
Take a look at JSONObject and JSONArray.
Example: