I am having the following response body via rest assured in 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
}
to extract all the name element values I am using the following code
String[] test_cycle_values;
JsonPath jsonPathEvaluator = response.jsonPath();
test_cycle_values = jsonPathEvaluator.get("*.[*].name");
the expected outcome I expect is Ad hoc, xyz_signIn
However I am getting Illegal argument exception for JsonPathEvauter
How can I retrive the name values from all the response body? JsonPathEvauter jar version is 3.0.5
If I use test_cycle_values = jsonPathEvaluator.get("7718.name");
I am getting it the value xyz_sign In
.*.name
this should do your job. Works for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.