继续在 Discourse API 文档 中的讨论:
你好
我找不到这个问题的答案,请问。有人知道是否可以指定 Discourse API 对 GET 请求的响应只返回请求的字段吗?
例如,列出组成员的 GET 请求(https://{defaultHost}/groups/{id}/members.json)返回:
{ "members": [ { "id": 0, "username": "string", "name": "string", "avatar_template": "string", "title": "string", "last_posted_at": "string", "last_seen_at": "string", "added_at": "string", "timezone": "string" } ], "owners": [ { "id": 0, "username": "string", "name": "string", "avatar_template": "string", "title": "string", "last_posted_at": "string", "last_seen_at": "string", "added_at": "string", "timezone": "string" } ], "meta": { "total": 0, "limit": 0, "offset": 0 } }
有没有办法让响应只返回一个特定字段?例如,只返回成员的用户名?
{
"members": [
{
"username": "string"
}
]
}
我知道可以通过检索整个响应,然后使用代码过滤 JSON 和数组以获取特定值,但是,我希望请求返回特定值。这可能吗?
谢谢!