drill icon indicating copy to clipboard operation
drill copied to clipboard

How to get a single field inside an array of assign?

Open LJason77 opened this issue 4 years ago • 4 comments

I have json:

{
    "count": 2,
    "rows": [
        {
            "_id": "aaa",
            "name": "AAA"
        },
        {
            "_id": "bbb",
            "name": "BBB"
        }
    ]
}

and benchmark.yml:

- name: get all
  request:
    url: /get_all
  assign: all

I want to get a single id, for example, this kind of:

- name: delete
  request:
    url: /del/{{ all.body.rows[0]._id }}
    method: DELETE

The above code is not working, what should I do?

LJason77 avatar Mar 10 '21 11:03 LJason77

Nowadays, the json access for previous requests doesn't support array steps. But it could be a really nice addition

fcsonline avatar Mar 15 '21 22:03 fcsonline

Maybe this merge can help you with more complex json accesses: https://github.com/fcsonline/drill/pull/114

fcsonline avatar Sep 02 '21 17:09 fcsonline

Executing OS commands to parse json in every request would be a performance killer.

Is there a way to implement this feature or there is a design complications that prevent this?

olka avatar Sep 08 '21 22:09 olka

Not super complicated, but it needs to be implemented.

fcsonline avatar Sep 16 '21 20:09 fcsonline