title: How do you return a JSON object from a Java Servlet
body: <p>How do you return a JSON object form a Java servlet.</p>
  
  <p>Previously when doing AJAX with a servlet I have returned a string. Is there a JSON object type that needs to be used, or do you just return a String that looks like a JSON object e.g. </p>
  
  <pre><code>String objectToReturn = "{ key1: 'value1', key2: 'value2' }";
  </code></pre>