title: Create Dynamic json in javascript
body: <p>I want to create a dynamic json string.
  Json looks like:</p>
  <pre><code>{
  &quot;getHostedPaymentPageRequest&quot;: {
      &quot;merchantAuthentication&quot;: {
          &quot;name&quot;: &quot;x345dsfg&quot;,
          &quot;transactionKey&quot;: &quot;456tyYYUU7876&quot;
      },
      &quot;transactionRequest&quot;: {
          &quot;transactionType&quot;: &quot;authCaptureTransaction&quot;,
          &quot;amount&quot;: &quot;20.00&quot;,
          &quot;profile&quot;: {
              &quot;customerProfileId&quot;: &quot;123456789&quot;
          }
      }
  }
  </code></pre>
  <p>}</p>
  <p>The values in json like name, transactionKey, transactionType, amount, customerProfileId will vary for different users.</p>
  <p>I am following this method to create json:</p>
  <pre><code>var getHostedPaymentPageRequest = new Object();            
  
      var merchantAuthentication = {};
      merchantAuthentication.name = &quot;x345dsfg&quot;;
      merchantAuthentication.transactionKey = &quot;456tyYYUU7876&quot;;
      var transactionRequest = {};
      transactionRequest.transactionType = &quot;&quot;;
      transactionRequest.amount = &quot;20.00&quot;;
  
      var profile = {};
      profile.customerProfileId = &quot;123456789&quot;;
  
      transactionRequest.profile = profile;
  
      getHostedPaymentPageRequest.merchantAuthentication = merchantAuthentication;
      getHostedPaymentPageRequest.transactionRequest = transactionRequest;
  
      getHostedPaymentPageRequest = JSON.stringify(getHostedPaymentPageRequest);
  </code></pre>
  <p>But its not giving back the right values.</p>
  <p>How do I make a valid json in the desired format?</p>