Hi! I have an iPhone application which gets a json string from a server and parses it. It contains some data and, eg. an array of comments. But I've noticed that the order of the json array is not preserved when I parse it like this:
// parse response as json
SBJSON *jsonParser = [SBJSON new];
NSDictionary *jsonData = [jsonParser objectWithString:jsonResponse error:nil];
NSDictionary* tmpDict = [jsonData objectForKey:@"rows"];
NSLog(@"keys coming!");
NSArray* keys = [tmpDict allKeys];
for (int i = 0;i< [keys count]; i++) {
NSLog([keys objectAtIndex:i]);
}
Json structure:
{ "pagerInfo":{
"page":"1",
"rowsPerPage":15,
"rowsCount":"100"
},
"rows":{
"18545":{
"id":"18545",
"text":"comment 1"
},
"22464":{
"id":"22464",
"text":"comment 2"
},
"21069":{
"id":"21069",
"text":"comment 3"
},
… more items
}
}
Does anyone know how to deal with this problem? Thank you so much!