开发者

Serializing to JSON or XML in Pylons

开发者 https://www.devze.com 2023-01-23 10:21 出处:网络
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.

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

精彩评论

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