For an application i want to create a JSON in format as mentioned below,
\"Students\" : {
\"results\": {
\"Grade1\": {
\"studentresul
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
NSMutableDictionary *grade = [[NSMutableDictionary alloc] init];
[grade setValue:@"pass" forKey:@"studentresult"];
[grade setValue:@"provided" forKey:@"marksheet"];
[result setValue:grade forKey:@"Grade1"];
[result setValue:@"01" forKey:@"ID"];
[result setValue:@"Student1" forKey:@"Name"];
[dict setValue:result forKey:@"results"];
NSMutableDictionary *stdnt = [[NSMutableDictionary alloc] init];
[stdnt setValue:dict forKey:@"Students"];
NSError *error = nil;
NSData *jsondata = [NSJSONSerialization dataWithJSONObject:stdnt options:NSJSONWritingPrettyPrinted error:&error];
NSString *s = [[NSString alloc] initWithData:jsondata encoding:NSUTF8StringEncoding];
NSLog(@"%@",s);
It may helps you.