title: Re-arrage JSON values from existing values
body: <p>The JSON provided is kind of unstructured and doesn't meet many of my 
     requirements. I have tried this many ways but does take a very long time 
     when I provide 100,000 records</p>
  
  <p><strong>Implemented Code</strong></p>
  
  <pre><code>for (var f in stack.data) {
    var field = new Object();
    for (var o in stack.data[f]['field_values']) {
      field[stack.data[f]['field_values'][o]['field_name']] = stack.data[f]['field_values'][o]['value'];
    }
    stack.data[f]['field_values'] = field;
  }
  console.log(JSON.stringify(stack, null, 2));
  </code></pre>
  
  <p><strong>Input JSON:</strong></p>
  
  <pre><code>var stack = {
    "data": [{
      "id": 950888888073,
      "name": "www.stackoverflow.com",
  
      "field_values": [{
          "field_name": "Newsletter?",
          "value": true
        },
        {
          "field_name": "Parent",
          "value": 950888661
        },
        {
          "field_name": "Birthday",
          "value": "2018-04-29"
        },
        {
          "field_name": "Related matter",
          "value": 1055396205
        },
        {
          "field_name": "Referral",
          "value": "Don Ho"
        },
        {
          "field_name": "Spouse",
          "value": "Wo Fat"
        }
      ]
    }]
  }
  </code></pre>
  
  <p><strong>Expected Output:</strong></p>
  
  <pre><code>{
    "data": [
    {
    "id": 950888888073,
    "name": "www.stackoverflow.com",
    "field_values": {
      "Newsletter?": true,
      "Parent": "Gigi Hallow",
      "Birthday": "2018-04-29",
      "Related": "2012-00121-Sass",
      "Referral": "Don Ho",
      "Spouse": "Wo Fat"
    }
  </code></pre>
  
  <p>Sometimes "field_values can be empty. Need to check them as well</p>
  
  <pre><code>     {
        "id": 950821118875,
        "name": "www.google.com",
        "field_values": [],
  }
  </code></pre>
  
  <p>This is mostly re-arranging the values. Here values becomes keys. There should actually be one liner to handle this, but i am run out of options.</p>
  
  <p>Hope the question is clear</p>