title: Merge Duplicate values with in a single array while json parsing in iOS
body: <p>I want to parse json and keep it in the local array so that I can display the data as like excell in my app. The json is redundant. I have uploaded an image for your kind consideration.
  Here is my json </p>
  
  <pre><code>    [
    {
      "date": "2018-10-21",
      "Status": "Confirmed",
      "Orders": "1"
    },
    {
      "date": "2018-10-22",
      "Status": "Confirmed",
      "Orders": "1"
    },
    {
      "date": "2018-10-22",
      "Status": "Delivered",
      "Orders": "2"
    },
    {
      "date": "2018-10-22",
      "Status": "Cancelled",
      "Orders": "1"
    },
    {
      "date": "2018-10-22",
      "Status": "Rejected",
      "Orders": "2"
    },
    {
      "date": "2018-10-22",
      "Status": "Cancelled",
      "Orders": "1"
    },
    {
      "date": "2018-10-22",
      "Status": "Cancelled",
      "Orders": "1"
    },
    {
      "date": "2018-10-23",
      "Status": "Cancelled",
      "Orders": "2"
    },
    {
      "date": "2018-10-23",
      "Status": "Processing",
      "Orders": "3"
    },
    {
      "date": "2018-10-24",
      "Status": "Cancelled",
      "Orders": "1"
    },
    {
      "date": "2018-10-25",
      "Status": "Delivered",
      "Orders": "1"
    },
    {
      "date": "2018-10-25",
      "Status": "Processing",
      "Orders": "2"
    },
    {
      "date": "2018-10-26",
      "Status": "Delivered",
      "Orders": "1"
    },
    {
      "date": "2018-10-27",
      "Status": "Processing",
      "Orders": "3"
    },
    {
      "date": "2018-10-27",
      "Status": "Processing",
      "Orders": "1"
    },
    {
      "date": "2018-10-27",
      "Status": "Processing",
      "Orders": "2"
    },
    {
      "date": "2018-10-28",
      "Status": "Confirmed",
      "Orders": "1"
    },
    {
      "date": "2018-10-28",
      "Status": "Delivered",
      "Orders": "3"
    },
    {
      "date": "2018-10-29",
      "Status": "Delivered",
      "Orders": "5"
    },
    {
      "date": "2018-10-29",
      "Status": "Processing",
      "Orders": "2"
    },
    {
      "date": "2018-10-29",
      "Status": "Rejected",
      "Orders": "1"
    },
    {
      "date": "2018-10-29",
      "Status": "Processing",
      "Orders": "1"
    },
    {
      "date": "2018-10-31",
      "Status": "Confirmed",
      "Orders": "2"
    },
    {
      "date": "2018-10-31",
      "Status": "Processing",
      "Orders": "2"
    },
    {
      "date": "2018-10-31",
      "Status": "Processing",
      "Orders": "1"
    },
    {
      "date": "2018-10-31",
      "Status": "Processing",
      "Orders": "1"
    },
    {
      "date": "2018-11-01",
      "Status": "Confirmed",
      "Orders": "1"
    },
    {
      "date": "2018-11-01",
      "Status": "Processing",
      "Orders": "1"
    },
    {
      "date": "2018-11-01",
      "Status": "Processing",
      "Orders": "2"
    },
    {
      "date": "2018-11-01",
      "Status": "Processing",
      "Orders": "1"
    },
    {
      "date": "2018-11-02",
      "Status": "Cancelled",
      "Orders": "1"
    },
    {
      "date": "2018-11-03",
      "Status": "Processing",
      "Orders": "4"
    },
    {
      "date": "2018-11-03",
      "Status": "Cancelled",
      "Orders": "1"
    },
    {
      "date": "2018-11-04",
      "Status": "Processing",
      "Orders": "1"
    }
  ]
  </code></pre>
  
  <p>After parsing it I want to keep the data of same date together. For example for a particular date like 2018-10-20 I would like to keep all the information in an entity class so that I can populate the information in the table. </p>
  
  <p><a href="https://i.stack.imgur.com/GEON1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GEON1.png" alt="enter image description here"></a></p>
  
  <p>My parsing code is provided below</p>
  
  <pre><code>    -(void)parseLocalJson
  {
      resultsArray=[[NSMutableArray alloc]init];
      NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Results" ofType:@"json"];
      NSString *myJSON = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL];
      NSArray *jsonArr = [NSJSONSerialization JSONObjectWithData:[myJSON dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:nil];
  
      for(int r =0;r&lt;[jsonArr count];)
      {
          id val=[jsonArr objectAtIndex:r];
          Results* prevResult;
          //Results* aResult;
          Results* aResult=[[Results alloc]init];
          aResult.date=[val valueForKey:@"date"];
  
  
           if(![aResult.date isEqualToString:prevResult.date])
          {
               //Results* aResult=[[Results alloc]init];
              NSString* status=[val valueForKey:@"Status"];
              NSString* orders=[val valueForKey:@"Orders"];
              if([status isEqualToString:@"Confirmed"])
              {
                  aResult.orderStatus_Confirmed=orders;
              }
              else if([status isEqualToString:@"Delivered"])
              {
                  aResult.orderStatus_Delivered=orders;
              }
              else if([status isEqualToString:@"Cancelled"])
              {
                  aResult.orderStatus_Cancelled=orders;
  
              }
              else if([status isEqualToString:@"Rejected"])
              {
                  aResult.orderStatus_Rejected=orders;
              }
              else if([status isEqualToString:@"Pending"])
              {
                  aResult.orderStatus_Pending=orders;
              }
              [resultsArray addObject:aResult];
              r++;
          }
          else
          {
              r--;
              NSString* status=[val valueForKey:@"Status"];
              NSString* orders=[val valueForKey:@"Orders"];
              if([status isEqualToString:@"Confirmed"])
              {
                  prevResult.orderStatus_Confirmed=orders;
              }
              else if([status isEqualToString:@"Delivered"])
              {
                  prevResult.orderStatus_Delivered=orders;
              }
              else if([status isEqualToString:@"Cancelled"])
              {
                  prevResult.orderStatus_Cancelled=orders;
  
              }
              else if([status isEqualToString:@"Rejected"])
              {
                  prevResult.orderStatus_Rejected=orders;
              }
              else if([status isEqualToString:@"Pending"])
              {
                  prevResult.orderStatus_Pending=orders;
              }
  
              //[resultsArray addObject:prevResult];
  
          }
          prevResult=aResult;
  
  
  
  
      }
  
  
  
  
  
      // Parse the string into JSON
      //NSDictionary *json = [myJSON JSONValue];
  }
  </code></pre>
  
  <p>I want to keep data in my array according to the image provided.  Please help me out. Thanks in advance. </p>