creating JSON format in Objective C

后端 未结 6 444
感动是毒
感动是毒 2020-12-10 07:19

For an application i want to create a JSON in format as mentioned below,

\"Students\" : {
    \"results\": {
        \"Grade1\": {
            \"studentresul         


        
6条回答
  •  北海茫月
    2020-12-10 08:05

    NSDictionary *gradedetails = @{@"studentresult" : @"pass", @"marksheet" : @"provided"};
    NSDictionary *grade = @{ @"Grade1" : gradedetails}
    NSDictionary *sdetails = @{@"ID" : @"01", @"Student1" : @"Name"};
    NSArray *resultsArray = @[grade, sdetails];
    NSDictionary *results= @{@"results" : resultsArray};
    NSDictionary *stud = @{@"Students" : results};
    
    NSData *jsondata = [NSJSONSerialization dataWithJSONObject:stud options:NSJSONWritingPrettyPrinted error:&error];
    

    I wonder why few developper use this notation

提交回复
热议问题