开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜