title: knockout.js save form to json
body: <p>I have my form mapped using knockout.js and mapping plugin. I am ready to save the form to json and send it back to the server. This is my first time doing this so what is the simplest way to do it?</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>// Here's my data model
  var viewModel;
  $.getJSON('/myJSONdata', function (data) {
      viewModel = ko.mapping.fromJS(data);
      ko.applyBindings(viewModel);
  });
  
  //convert mapped data to json format
  var jsonData = ko.mapping.toJSON(viewModel);
  
  // Do something to send the form data in json format back to the server on form submit
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;form data-bind="submit: doSomething"&gt;
    &lt;label for="typeOfIncident"&gt;Do you agree?&lt;/label&gt;
    &lt;label&gt;
    &lt;input type="radio" name="doYouAgree" value="Yes" data-bind="value: doYouAgree" checked&gt;
    Yes
    &lt;/label&gt;
    &lt;label&gt;
    &lt;input type="radio" name="doYouAgree" value="No" data-bind="value: doYouAgree"&gt;
    No
    &lt;/label&gt;
  
    &lt;!-- submit button --&gt;
    &lt;button type="submit"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>