CherryPy How to respond with JSON?
Since CherryPy 3.2 there are tools to accept/return JSON:
@cherrypy.expose@cherrypy.tools.json_out()def monkey(self, **params): return {"message": "Hello World!"}
Using json_out
serializes the output and sets the appropriate Content-Type header for you.
Similarly decorating with @cherrypy.tools.json_in()
can automatically accept/decode JSON post requests.