title: Merge JSON object value to Array by it duplicate key and value [javascript]
body: <p>i want to merge some value object with same key and value, in this case <code>"field_template_id": 2</code> is duplicate but have different value.</p>
  
  <p>json data : </p>
  
  <pre><code>{
    "id": "c2dec94f",
    "data": [
      {
        "field_template_id": 1,
        "value": "111"
      },
      {
        "field_template_id": 2,
        "value": 222
      },
      {
        "field_template_id": 2,
        "value": 444
      },
      {
        "field_template_id": 3,
        "value": [
          333
        ]
      }
    ]
  }
  </code></pre>
  
  <p>i expected to be like this, there still <code>"field_template_id": 2</code> but the value is array.</p>
  
  <p>expected json :</p>
  
  <pre><code>{
    "id": "c2dec94f",
    "data": [
      {
        "field_template_id": 1,
        "value": "111"
      },
      {
        "field_template_id": 2,
        "value": [
          222, 444
        ]
      },
      {
        "field_template_id": 3,
        "value": [
          333
        ]
      }
    ]
  }
  </code></pre>
  
  <p>Thanks in advance</p>