Serializing to JSON or XML in Pylons
Is there a quick way开发者_StackOverflow to serialize Python data structures to JSON/XML in Pylons, like there is in Django?
There is the jsonify decorator.
http://pylonshq.com/docs/en/1.0/modules/decorators/
from pylons.decorators import jsonify
class MyController(BaseController):
@jsonify
def action(self):
my_object = dict(foo='bar')
return my_object
Yes: you are looking for the simplejson module. Currently, this module is installed when you install Pylons. Its documentation lives here, and it's a very straightforward module for most use cases.
精彩评论