获取如下所示的API响应,并希望使用可放心的方法来获取所有字段的名称。
{
"expand": "projects",
"projects": [
{
"expand": "issuetypes",
"issuetypes": [
{
"subtask": false,
"expand": "fields",
"fields": {
"summary": {
"required": true,
"schema": {
"type": "string",
"system": "summary"
},
"name": "Summary",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"customfield_10100": {
"required": false,
"schema": {
"type": "any",
"custom": "com.pyxis.greenhopper.jira:gh-epic-link",
"customId": 10100
},
"name": "Epic Link",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"customfield_10102": {
"required": true,
"schema": {
"type": "string",
"custom": "com.pyxis.greenhopper.jira:gh-epic-label",
"customId": 10102
},
"name": "Epic Name",
"hasDefaultValue": false,
"operations": [
"set"
]
},
}
}
]
}
]
}
我尝试使用respStg1.jsonPath().getList("projects.issuetypes.fields.[*].name")
获取名称,但出现gpath错误。如果有任何方法可以获取projects.issuetypes.fields下所有字段的名称,请提供帮助。
答案 0 :(得分:0)
尝试使用此= [*].[*].[*].[*].name
这应该工作
为了将来,您可以使用此链接评估jsonPath:http://jsonpath.com/
,有关JSONPath语法和通配符,请参考以下链接:https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html