在 中flask-restplus,我想对具有嵌套列表结构的响应主体进行建模,因此每当进行 api 调用时,响应主体都会返回我期望的内容。在响应主体中,它有一个嵌套结构,我不知道如何记录它。我要用吗fields.Dict()?谁能在这里指出我如何实现这一点flask-restplus?
响应正文:
{
"score": 0,
"category": "low",
"guidance": "string",
"is_ready": true,
"used_features": [
{
"name": "hear_rate",
"value": 1002,
"range_value": [
10,
1000,
10000,
20000
],
"range_frequency": [
80,
15,
2,
1
],
"importance": 1
},
{
"name": "pressure",
"value": 400,
"range_value": [
10,
1000,
3000
],
"range_frequency": [
85,
10,
5
],
"importance": 2
}
]
}
Run Code Online (Sandbox Code Playgroud)
我的部分解决方案:
这是我的部分解决方案
from flask import Flask, jsonify
from flask_restplus import Api, Resource, …Run Code Online (Sandbox Code Playgroud)