我在java中通过rest保证了下面的响应体
{
"-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}
为了提取所有name元素值,我使用以下代码
String[] test_cycle_values;
JsonPath jsonPathEvaluator = response.jsonPath();
test_cycle_values = jsonPathEvaluator.get("*.[*].name");我期望的预期结果是即席的,xyz_signIn
但是,我得到了JsonPathEvauter的非法参数异常
如何从所有响应体中检索Name值?JsonPathEvauter jar版本为3.0.5
如果我使用test_cycle_values = jsonPathEvaluator.get("7718.name");
我正在获取它的值xyz_sign In
发布于 2019-01-17 04:46:29
.*.name 这应该可以完成您的工作。这对我很有效。
https://stackoverflow.com/questions/54224785
复制相似问题