title: Check for duplicates in JSON
body: <p>I have a json object:</p>
  
  <pre><code> var object1 =  [{
          "value1": "1",
          "value2": "2",
          "value3": "3",
      },
      {
          "value1": "1",
          "value2": "5",
          "value3": "7",
      },
      {
          "value1": "6",
          "value2": "9",
          "value3": "5",
      },
      {
          "value1": "6",
          "value2": "9",
          "value3": "5",
      }]
  </code></pre>
  
  <p>Now I want to take each record out of that object and check how many times exact copy of that record is appearing in that object. If it is only 1 copy do something and if it is more than 2 do something else. </p>
  
  <p>There are few answers on JSON duplicates but they target specific value not full record. </p>
  
  <p>So I will take the record: </p>
  
  <pre><code>   {
          "value1": "1",
          "value2": "2",
          "value3": "3",
      }
  </code></pre>
  
  <p>and compare it against the object. The above record will return 1 as there is only 1 copy inside the object</p>
  
  <p>For Future use. The full answer would be:</p>
  
  <pre><code>var asset = [
      { value1: "1", value2: "2", value3: "3" },
      { value1: "1", value2: "5", value3: "7" },
      { value1: "6", value2: "9", value3: "5" },
      { value1: "6", value2: "9", value3: "5" }
  ];
  
  function countEqual(oo, pp) {
      var count = 0;
      oo.forEach(function (el) {
          var i, equal = true;
          for (i in el) {
              equal = equal &amp;&amp; el[i] === pp[i];
          }
          equal &amp;&amp; count++;
      });
      return count;
  }
  
          var cleaned = [];
  
          asset.forEach(function (itm) {
              var unique = true;
              cleaned.forEach(function (itm2) {
                  if (_.isEqual(itm, itm2)) unique = false;
              });
              if (unique) cleaned.push(itm);
          });
  
          for (var i = 0; i &lt; cleaned.length; i++)
          {
              if(countEqual(asset, cleaned[i]) === 1)
                 {
                     // DO SOMETHING
                 }
              else
                 {
                    // DO SOMETHING ELSE
                 }
          }
  </code></pre>