Hi,
Below is my json response and I am trying to verify each json in the list under result.
.check(jsonPath(stringToExpression("$.result[?(@.type == ‘auth’ && @.exercise_status == ‘EXERCISED’)]")).count.is(1))
.check(jsonPath(stringToExpression("$.result[?(@.type == ‘auth’ && @.value == 50000)]")).count.is(1))
.check(jsonPath(stringToExpression("$.result[?(@.exercise_status == ‘EXERCISED’ && @.value == 50000)]")).count.is(1))
.check(jsonPath(stringToExpression("$.result[?(@.type == ‘auth’ && @.value == 50000 && @.exercise_status == ‘EXERCISED’)]")).count.is(1))
the first three checks pass
but the last one fails
jsonPath($.result[?(@.type == ‘auth’ && @.value == 50000 && @.exercise_status == ‘EXERCISED’)]).count.is(1) failed, could not extract: could not extract : )]' expected but
&’ found
it looks like the issue is with 2nd “&&”
{
“jsonrpc”: “2.0”,
“id”: 1006,
“result”: [
{
“diner_id”: “81084010-01ec-11e6-8a06-5582f188d60b”,
“payment_id”: “12346687-e9c0-47ea-be3d-19b28aa77744”,
“type”: “auth”,
“transaction_id”: “5fy9nh”,
“payment_processor”: “braintree”,
“anonymous”: false,
“avs_postal_code_response_code”: “M”,
“brand”: “testing”,
“exercise_status”: “PENDING”,
“processor_response_code”: “1000”,
“processor_response_text”: “Approved”,
“order_id”: “0b48dcdd-756e-4cbd-b0ae-93b629433ad3”,
“time_bucket”: “2016-04-13T21:56:00.000Z”,
“transaction_time”: “2016-04-14T02:56:35.396Z”,
“validation_errors”: {},
“value”: 40000,
“restaurant_name”: “gatling test”,
“credit_card_last_four”: “1117”
},
{
“diner_id”: “81084010-01ec-11e6-8a06-5582f188d60b”,
“payment_id”: “12346687-e9c0-47ea-be3d-19b28aa77744”,
“type”: “auth”,
“transaction_id”: “fysnch”,
“payment_processor”: “braintree”,
“anonymous”: false,
“avs_postal_code_response_code”: “M”,
“brand”: “testing”,
“exercise_status”: “EXERCISED”,
“processor_response_code”: “1000”,
“processor_response_text”: “Approved”,
“order_id”: “0b48dcdd-756e-4cbd-b0ae-93b629433ad3”,
“time_bucket”: “2016-04-13T21:56:00.000Z”,
“transaction_time”: “2016-04-14T02:56:35.396Z”,
“validation_errors”: {},
“value”: 50000,
“restaurant_name”: “gatling test”,
“credit_card_last_four”: “1117”
},
{
“diner_id”: “81084010-01ec-11e6-8a06-5582f188d60b”,
“payment_id”: “12346687-e9c0-47ea-be3d-19b28aa77744”,
“type”: “voidTransaction”,
“transaction_id”: “5fy9nh”,
“payment_processor”: “braintree”,
“anonymous”: false,
“avs_postal_code_response_code”: “M”,
“brand”: “testing”,
“processor_response_code”: “1000”,
“processor_response_text”: “Approved”,
“order_id”: “0b48dcdd-756e-4cbd-b0ae-93b629433ad3”,
“time_bucket”: “2016-04-14T02:56:00.000Z”,
“transaction_time”: “2016-04-14T02:56:35.396Z”,
“validation_errors”: {},
“value”: 40000,
“restaurant_name”:“gatling test”,
“credit_card_last_four”: “1117”
},
{
“diner_id”: “81084010-01ec-11e6-8a06-5582f188d60b”,
“payment_id”: “12346687-e9c0-47ea-be3d-19b28aa77744”,
“type”: “settlement”,
“transaction_id”: “fysnch”,
“payment_processor”: “braintree”,
“anonymous”: false,
“avs_postal_code_response_code”: “M”,
“brand”: “testing”,
“processor_response_code”: “”,
“processor_response_text”: “”,
“order_id”: “0b48dcdd-756e-4cbd-b0ae-93b629433ad3”,
“time_bucket”: “2016-04-14T02:56:00.000Z”,
“transaction_time”: “2016-04-14T02:56:35.602Z”,
“validation_errors”: {},
“value”: 50000,
“restaurant_name”: “gatling test”,
“credit_card_last_four”: “1117”
}
]
}
i tried this here http://jsonpath.com/?
for the same json response above
$.result[?(@.type == ‘auth’ && @.exercise_status == ‘EXERCISED’ && @.value == 50000)]
and it worked.
Any help is appreciated.
Thanks