我有一本像下面这样的字典
{
"a": 2,
"b": 1,
"dd": {
"xx": {
"name": "Xx XxRay",
"guid": "967436db-3f7b-40c3-94cb-45c7ac5a1787"
},
"yy": {
"name": "Yy YyZee",
"guid": "db12b2b3-554d-42a8-b34e-9995c9719999"
}
}
}
我正在尝试在 Restx 中使用 marhsall ,但无法使其正常工作。
首先,我定义了内部结构
details_model = api.model('Details', {
"name": fields.String(required=True,
description='Name'),
"guid": fields.String(required=False, description='GUID')
})
其次,我定义了我目前没有使用的。
dd_model = api.model('dd', {
'shortname': fields.Nested(details_model)
})
最后,
response_model = api.model('Response', {
'a': fields.Integer(min=0, description='Total Number of Results'),
'b': fields.Integer(min=0, description='Total Number of X'),
'dd': fields.Nested(fields.String, details_model)
})
我该如何构建这个结构?