title: Google app engine json response as REST
body: <p>How can I response a page as a json page? Is the code below correct?</p>
  
  <pre><code>from google.appengine.ext import webapp
  from google.appengine.ext.webapp.util import run_wsgi_app
  import json
  
  class JsonPage(webapp.RequestHandler):
      def get(self):
          self.response.header['Content-Type'] = 'application/json'
          self.response.out.write(json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]))
  
  application = webapp.WSGIApplication([('json', JsonPage)], debug=True)
  
  def main():
      run_wsgi_app(application)
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code>HTTP request sent, awaiting response... 404 Not Found
  2012-05-06 14:10:01 ERROR 404: Not Found.
  </code></pre>
  
  <hr>
  
  <p>After make some changes to the code, I got the following error, seem like the dumps object cannot be found in the json module :</p>
  
  <pre><code>&lt;pre&gt;Traceback (most recent call last):
    File &amp;quot;/opt/google_appengine/google/appengine/ext/webapp/_webapp25.py&amp;quot;, line 701, in __call__
      handler.get(*groups)
    File &amp;quot;/home/kelvin/workspace/cloudnuts/json.py&amp;quot;, line 8, in get
      self.response.out.write(json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]))
  AttributeError: 'module' object has no attribute 'dumps'
  &lt;/pre&gt;
  </code></pre>