I’m reading a JSON code such as:
[{"question_id":"1",
"trigger_value":"Yes",
"question_text":"What is your first name?",
"question_type":"YN"},
{"question_id":"2",
"trigger_value":"Yes",
"question_text":"What is your second name?",
"question_type":"YN"}
]
But once it’s set into NSMutableArray, the duplicate values are deleted. I would like to allow them to check the question_type for each question.
NSString *question_id;
NSString *question_text;
NSString *question_type;
while (dicjson = (NSDictionary*)[enumerator nextObject]) {
question_id = [dicjson objectForKey:@"question_id"];
question_type = [dicjson objectForKey:@"question_type"];
[mutjson setObject:question_id forKey:question_type];
}
Would you give me any idea of allowing duplicate values…?
Thanks in advance.
mutjson looks like a mutable dictionary and not a mutable Array.
So yes, in a dictionary object if you are setting the same key, it will overwrite the previous value.
If you need to store dictionary object, create a mutable array and add each object inside that array as a dintionary object…