我在Java中通过放心获得以下响应正文
{
"-1": {
"totalExecutions": 0,
"endDate": "",
"description": "",
"totalExecuted": 0,
"started": "",
"versionName": "Unscheduled",
"expand": "executionSummaries",
"projectKey": "test",
"versionId": -1,
"environment": "",
"totalCycleExecutions": 0,
"build": "",
"ended": "",
"name": "Ad hoc",
"modifiedBy": "",
"projectId": 99,
"startDate": "",
"executionSummaries": {
"executionSummary": [
]
}
},
"7718": {
"totalExecutions": 1,
"endDate": "",
"description": "",
"totalExecuted": 1,
"started": "",
"versionName": "Unscheduled",
"expand": "executionSummaries",
"projectKey": "test",
"versionId": -1,
"environment": "",
"totalCycleExecutions": 1,
"totalDefects": 0,
"build": "",
"createdBy": "xyz",
"ended": "",
"name": "xyz_SignIn",
"totalFolders": 0,
"modifiedBy": "xyz",
"projectId": 99,
"createdByDisplay": "xyz",
"startDate": "",
"executionSummaries": {
"executionSummary": [
]
}
},
"recordsCount": 2
}
使用以下代码提取我正在使用的所有名称元素值
String[] test_cycle_values;
JsonPath jsonPathEvaluator = response.jsonPath();
test_cycle_values = jsonPathEvaluator.get("*.[*].name");
我期望的预期结果是 临时xyz_signIn
但是我收到JsonPathEvauter的非法参数异常
如何从所有响应正文中检索名称值? JsonPathEvauter jar版本是3.0.5
如果我使用 test_cycle_values = jsonPathEvaluator.get(“ 7718.name”);
我得到的值是xyz_sign In
答案 0 :(得分:1)
.*.name
这应该可以完成您的工作。为我工作。