Python 使用烧瓶Restful';s字段,我如何有一个;catchall“;领域

Python 使用烧瓶Restful';s字段,我如何有一个;catchall“;领域,python,json,rest,flask,flask-restful,Python,Json,Rest,Flask,Flask Restful,我正在使用。我希望有一个结构化的封送处理,但是有一个可以包含任何其他有效JSON数据的任意字段 例如,假设我有一个用于具有“name”和“birth_date”的用户的资源,但也有一个包含任意JSON的“preferences”字段: from flask_restful import Resource, marshal_with, fields import datetime class MyResource(Resource): resource_fields = {

我正在使用。我希望有一个结构化的封送处理,但是有一个可以包含任何其他有效JSON数据的任意字段

例如,假设我有一个用于具有“name”和“birth_date”的用户的资源,但也有一个包含任意JSON的“preferences”字段:

from flask_restful import Resource, marshal_with, fields
import datetime
class MyResource(Resource):
    resource_fields = {
        'name': fields.String,
        'birth_date': fields.DateTime,
        'preferences': fields.GeneralJson
    }

    @marshal_with(resource_fields)
    def get(self):
        return {'name': 'Newbie Newborn',
                'birth_date': datetime.datetime.now(),
                'preferences': {
                    'wine': 'cab-sav',
                    'cheese': 'cheddar',
                    'favorite_movies': ['The Big Lebowski', 'Anchorman']}
                }

当然,问题在于
字段.GeneralJson
不存在。如何使用Flask Restful定义JSON模式的“无模式”部分。您可以只使用
字段.Raw