I have a dictionary called array:
{
"encoding": "320",
"format": "MP3",
"media": "CD",
"name": "foo",
"remaster_title": ""
},
{
"encoding": "V0 (VBR)",
"format": "MP3",
"media": "CD",
"name": "bar",
"remaster_title": ""
},
{
"encoding": "Lossless",
"format": "FLAC",
"media": "CD",
"name": "bar",
"remaster_title": "hoho"
}
I want to separate them so that they are unique. For example, there should be only one name, so there will be two sections: fooand bar.
Then inside each name( fooor bar) should be remaster_title(for foo: and barboth: and hoho) ....
This should be in order name > remaster_title > media > format > encoding.
I think this would work if I had a format similar to:
music[name][remaster_title][media][format] = encoding
so that all the keys then merge?
I tried:
+(NSMutableDictionary*)handleReturnedArtistJson:(NSDictionary*)json{
NSMutableDictionary *music = [[NSMutableDictionary alloc] init];
for(NSDictionary *result in json[@"response"][@"group"]) {
NSString* release_type = result[@"releaseType"];
NSString* name = result[@"groupName"];
if (![release_type isEqual: @"Compilation"]){
for (NSDictionary *subgroup in result[@"subgroup"]){
NSString* media = subgroup[@"media"];
NSString* remaster_title = subgroup[@"remasterTitle"];
NSString* format = subgroup[@"format"];
NSString* encoding = subgroup[@"encoding"];
music[name][remaster_title][media][format] = encoding;
}
}
}
return music;
}
but NSLog(@"%@",music);returns nothing.