diff --git a/integration/hurl/tests_ok/assert_json.hurl b/integration/hurl/tests_ok/assert_json.hurl index 6b129bc7b5c..b9519b50adb 100644 --- a/integration/hurl/tests_ok/assert_json.hurl +++ b/integration/hurl/tests_ok/assert_json.hurl @@ -129,6 +129,59 @@ jsonpath "$.fruit.[?(@.US == 100)]" count == 0 # To be clarified with spec: th ] } +GET http://localhost:8000/assert-json/filter-by-name +HTTP 200 +[Asserts] + +jsonpath "$..*[?(@.name)]" count == 5 +jsonpath "$..*[?(@.name=='car')].id" nth 0 == 1 +jsonpath "$..*[?(@.name=='wheel')].id" nth 0 == 4 + +jsonpath "$..items[?(@.name)]" count == 5 +jsonpath "$..items[?(@.name=='car')].id" nth 0 == 1 +jsonpath "$..items[?(@.name=='wheel')].id" nth 0 == 4 + +jsonpath "$.main.items[?(@.name)]" count == 3 +jsonpath "$.main.items[?(@.name=='car')].id" nth 0 == 1 +jsonpath "$.main.items[?(@.name=='wheel')].id" isEmpty + +jsonpath "$.main..items[?(@.name)]" count == 4 +jsonpath "$.main..items[?(@.name=='car')].id" nth 0 == 1 +jsonpath "$.main..items[?(@.name=='wheel')].id" nth 0 == 4 + +{ + "main": { + "items": [ + { + "id": 1, + "name": "car" + }, + { + "id": 2, + "name": "bike", + "items": [ + { + "id": 4, + "name": "wheel" + } + ] + }, + { + "id": 3, + "name": "plane" + } + ] + }, + "more": { + "items": [ + { + "id": 5, + "name": "scooter" + } + ] + } +} + GET http://localhost:8000/assert-json/big-number HTTP 200 [Asserts] diff --git a/integration/hurl/tests_ok/assert_json.py b/integration/hurl/tests_ok/assert_json.py index c68fcefa360..8d29a4a0180 100644 --- a/integration/hurl/tests_ok/assert_json.py +++ b/integration/hurl/tests_ok/assert_json.py @@ -61,6 +61,43 @@ def assert_json_filter(): mimetype="application/json", ) +@app.route("/assert-json/filter-by-name") +def assert_json_filter_ny_name(): + return Response( + """{ + "main": { + "items": [ + { + "id": 1, + "name": "car" + }, + { + "id": 2, + "name": "bike", + "items": [ + { + "id": 4, + "name": "wheel" + } + ] + }, + { + "id": 3, + "name": "plane" + } + ] + }, + "more": { + "items": [ + { + "id": 5, + "name": "scooter" + } + ] + } +}""", + mimetype="application/json", + ) @app.route("/assert-json/big-number") def assert_json_big_number():