title: JSON transformation in node.js
body: <p>I want to transform my data from one json structure to another. What is the best way to do it?</p>
  
  <p>Here is my original resource (customer) structure is:</p>
  
  <pre><code>{
    "id": "123",
    "data": {
      "name": "john doe",
      "status": "active",
      "contacts": [
        {
          "email": "john@email.com"
        },
        {
          "phone": "12233333"
        }
      ]
    }
  }
  </code></pre>
  
  <p>I want to change it to:</p>
  
  <pre><code>{
    "id": "123",
    "name": "john doe",
    "status": "active",
    "contacts": [
      {
        "email": "john@email.com"
      },
      {
        "phone": "12233333"
      }
    ]
  }
  </code></pre>
  
  <p>Keeping in mind that I might have an <em>array</em> of resources(customers) being returned in GET /customers cases. I want to change that to an array of new data type.</p>