My json array is like this:
[
{
"result_names": [
"val"
]
},
{
"result_names": [
"val"
]
},
{
"result_names": [
"count",
"sum"
]
}
]
My output should just be an array with string val, count and sum at array indices 0, 1 and 2 (order doesn't matter) and duplicates should be removed ("val" is repeated twice). I am able to get rid of the duplicates but I am not quite sure to get the third occurrence of result_names at separate indices. Here's my code so far:
Above json is stored as:
NSDictionary* json;
NSMutableArray *resultList = [json valueForKey:@"result_names"];
NSArray *res = [[NSSet setWithArray: resultList] allObjects];
Now, NSLog(@"%@", res); gives me:
(
val
),
(
count,
sum
)
)
Now "res.count" returns 2. I want val, count and sum in different indices. Kindly help.