I get a return array by json,
[{"date": "2011-01-01", "title": "aaa"},
{"date": "2011-01-01", "title": "bbb"},
{"date": "2011-01-01", "title": "ccc"},
{"date": "2011-01-02", "title": "ddd"},
{"date": "2011-01-02", "title": "eee"},
{"date": "2011-01-03", "title": "fff"},
{"date": "2011-01-03", "title": "ggg"}]
I use these code to get the value:
NSDictionary *jsonDictionary = [jsonArray objectAtIndex:i];
NSString *date = [jsonDictionary objectForKey:@"dispalyDate"];
NSString *title = [jsonDictionary objectForKey:@"title"];
The problem is how can I restructure the array or create new array according to the same date, such as
date = 2011-01-01
aaa、bbb、ccc
date = 2011-01-02
ddd、eee
date = 2011-01-03
fff、ggg
Something like this…
Now you have a dictionary where the keys are date strings and the values are title arrays. If you really want an array result, you can then do this: