title: Create JSON object from vuejs form data
body: <p>I'm trying to create a JSON object from form data on submit.</p>
  <p>I've managed to get it working with a variable. Is there a better way to create a JSON object?</p>
  <p><strong>Form</strong></p>
  <pre><code>&lt;form @submit.prevent=&quot;submit&quot;&gt;
     &lt;div class=&quot;form-group&quot;&gt;
        &lt;label class=&quot;inputa-label&quot; for=&quot;exampleInputEmail1&quot;
           &gt;Email address&lt;/label
           &gt;
        &lt;input
           type=&quot;email&quot;
           class=&quot;form-control inputa&quot;
           id=&quot;exampleInputEmail1&quot;
           placeholder=&quot;Enter email&quot;
           required
           v-model=&quot;email&quot;
           /&gt;
     &lt;/div&gt;
     &lt;div class=&quot;form-group&quot;&gt;
        &lt;label class=&quot;inputa-label&quot; for=&quot;exampleInputPassword1&quot;
           &gt;Phone number&lt;/label
           &gt;
        &lt;input
           type=&quot;number&quot;
           class=&quot;form-control inputa&quot;
           id=&quot;exampleInputPassword1&quot;
           placeholder=&quot;Phone&quot;
           v-model=&quot;phone&quot;
           /&gt;
     &lt;/div&gt;
     &lt;div class=&quot;form-group&quot;&gt;
        &lt;label class=&quot;inputa-label&quot; for=&quot;exampleInputPassword1&quot;
           &gt;Information&lt;/label
           &gt;
        &lt;textarea
           class=&quot;form-control inputa&quot;
           aria-label=&quot;With textarea&quot;
           v-model=&quot;information&quot;
           &gt;&lt;/textarea&gt;
     &lt;/div&gt;
     &lt;button
        type=&quot;submit&quot;
        style=&quot;font-weight:600; padding: .8125rem 1.25rem&quot;
        class=&quot;btn btn-primary&quot;
        &gt;
     Submit
     &lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p><strong>Method:</strong></p>
  <pre><code>  data() {
      return {
        email:&quot;&quot;,
        phone:&quot;&quot;,
        information:&quot;&quot;,
      };
    },
    methods: {
      submit() {
  
        var data = '{ &quot;Email&quot;:&quot;' + this.email + '&quot; , &quot;Phone&quot;:&quot;' + this.phone + '&quot;, &quot;Information&quot;:&quot;' + this.information + '&quot; }';
        
      },
    },
  </code></pre>
  <p>I've got it working with a variable, but I want to know if there is a better way to do this.</p>