title: Swift - Finding duplicate Json data and merging
body: <p>I'm using swiftyjson to mess around with my json data. </p>
  
  <p>Currently, i'm receiving data that has values I want to merge together. (it'll make more sense if you take a look at the example below. I'v tried many different approaches such as using a for loop to go through the JSON data but that duplicates everything. I have also tried changing my json to a 2d array then filtering it, but it seems like that is complicating things. There has to be an easier way... </p>
  
  <pre><code>var jsondata = {
  {
      fruit: "APPLE"
      amount: 10
  },{
      fruit: "Mango"
      amount: 5 
  },{
      fruit: "APPLE"
      amount: 5 
  },{
      fruit: "Mango"
      amount: 5 
  },{
      fruit: "orange"
      amount: 500
  }
  }
  
  
  var NEWjsondata = 
  {
      {
      fruit: "APPLE"
      amount: 15
      },
      {
      fruit: "Mango"
      amount: 10
      },
      {
      fruit: "orange"
      amount: 500
      }
  }
  </code></pre>
  
  <p>My approach</p>
  
  <pre><code>var arr = ["Apple","Mango","Orange"]
  for (key,json) in jsondata {
  arr.append(json["fruit"])
  if arr.contains(json["fruit"]){
  json["amount"] = json["amount"] + json["amount"]
  }}
  </code></pre>