title: Ext JS 4: Convert JSON object to another JSON object using JavaScript
body: <p>What is the easiest way to convert JSON A to JSON B using JavaScript?</p>
  
  <p><strong>JSON A:</strong></p>
  
  <pre><code>{
      "d":
      [
          {"__type":"Web.Controls.Shared.GeneralService+DropdownKeyValuePair","key":"0","value":"one"},
          {"__type":"Web.Controls.Shared.GeneralService+DropdownKeyValuePair","key":"1","value":"two"},
          {"__type":"Web.Controls.Shared.GeneralService+DropdownKeyValuePair","key":"2","value":"three"}
      ]
  }
  </code></pre>
  
  <p><strong>JSON B:</strong></p>
  
  <pre><code>{
      data:
      [
          {"key":"1", "value":"one"},
          {"key":"2", "value":"two"},
          {"key":"3", "value":"three"}
      ]
  }    
  </code></pre>
  
  <p>===================</p>
  
  <h1>8/1/2012 update (answer when using Ext JS and you have an ASP.NET proxy:</h1>
  
  <p>I didn't provide this in my question about what I'm using for a JavaScript framework, but it turns out you can implicitly eliminate the "d" key by specifying the value "d" in the root property </p>
  
  <pre><code>var statusDropdownStore = new Ext.data.Store({
      proxy: new Ext.ux.AspWebAjaxProxy({
          url: '/track/Controls/Shared/GeneralService.asmx/GetDropdownOptions',
          actionMethods: {
              create: 'POST',
              destroy: 'DELETE',
              read: 'POST',
              update: 'POST'
          },
          extraParams: {
              user_login: authUser,
              table_name: '[status]'
          },
          reader: {
              type: 'json',
              model: 'DropdownOption',
              root: 'd'
          },
          headers: {
              'Content-Type': 'application/json; charset=utf-8'
          }
      })
  });
  </code></pre>
  
  <p><strong>Proxy:</strong></p>
  
  <pre><code>Ext.define('Ext.ux.AspWebAjaxProxy', {
      extend: 'Ext.data.proxy.Ajax',
      require: 'Ext.data',
  
      buildRequest: function (operation) {
          var params = Ext.applyIf(operation.params || {}, this.extraParams || {}),
                                  request;
          params = Ext.applyIf(params, this.getParams(params, operation));
          if (operation.id &amp;&amp; !params.id) {
              params.id = operation.id;
          }
  
          params = Ext.JSON.encode(params);
  
          request = Ext.create('Ext.data.Request', {
              params: params,
              action: operation.action,
              records: operation.records,
              operation: operation,
              url: operation.url
          });
          request.url = this.buildUrl(request);
          operation.request = request;
          return request;
      }
  });
  </code></pre>
  
  <p><strong>Combo Box (dropdown) configuration:</strong></p>
  
  <pre><code>                    {
                          xtype: 'combo',
                          fieldLabel: 'Status',
                          emptyText: 'Select a status...',
                          store: statusDropdownStore,
                          valueField: 'key',
                          displayField: 'value',
                          mode: 'remote',  // or 'local'
                          renderTo: document.body
                      },
  </code></pre>