title: How do I encode a JavaScript object as JSON?
body: <p>Is there a good way to encode a JavaScript object as JSON?</p>
  
  <p>I have a list of key value pairs...where the name is from a checkbox, and the value is either true or false based on whether the box is checked or not:</p>
  
  <pre><code>var values = {};
  $('#checks :checkbox').each(function() { values[this.name]=this.checked; }); 
  </code></pre>
  
  <p>I want to pass these values into a JSON object so store into a cookie to render a table (Columns will be added according to what the user checks off).</p>
  
  <p>Does anyone know a solution? </p>