from flask.ext.restful import fields, marshal
data = { 'a': 100, 'b': 'foo' }
mfields = { 'a': fields.Raw }
marshal(data, mfields)
OrderedDict([('a', 100)])
marshal(data, mfields, envelope='data')
OrderedDict([('data', OrderedDict([('a', 100)]))])
Parameters: |
- data – the actual object(s) from which the fields are taken from 可以是对象
- fields – a dict of whose keys will make up the final serialized response output 定义的字典
- envelope – optional key that will be used to envelop the serialized response用于封装序列化响应的可选键
|
---|