title: sending a post request with json data that contains a list
body: <p>Solved.  The solution is to set contentType to 'application/json' and use the JSON.stringify(obj) instead of obj, but you may then have to change how you get the data on your server, depending on the language or framework.  Original question below...</p>
  
  <p>Here's what I'm trying</p>
  
  <pre><code>var obj = {
      'firstName': 'bill',
      'lastName': 'johnson',
      'hobbies': ['apples', 'dogs']
      });
  $.ajax({
      type: 'POST',
      url: '/myurl'
      data: obj,
      success: function(data){alert(data);}
      });
  </code></pre>
  
  <p>If I alert/log a <code>JSON.stringify(obj)</code>, I get the correct result, i.e.:</p>
  
  <pre><code>{'firstName': 'bill', 'lastName': 'johnson', 'hobbies': ['apples', 'dogs']}
  </code></pre>
  
  <p>However, when I do the above ajax call, my server gets the following:</p>
  
  <pre><code>{'firstName': 'bill', 'lastName': 'johnson', 'hobbies[]': 'apples'}
  </code></pre>
  
  <p>Which clearly is not proper json.  I've tried adding various <code>contentType</code> arguments but then my server actually gets nothing (an empty post request).</p>
  
  <p>I also tried setting the data argument to a pre-stringified string of JSON (which is correct), but then jquery escapes it and my server gets this:</p>
  
  <pre><code>{"{\"firstName\":\"bill\",\"lastName\":\"johnson\",\"hobbies\":[\"apples\",\"dogs\"]}": ""}
  </code></pre>
  
  <p>I tried setting <code>processData</code> to <code>false</code> and that changes nothing.</p>
  
  <p>I've researched this for hours and haven't gotten it to work.  Surely there's a way to send json with lists to the server...</p>
  
  <p>any tips?</p>