mitymouse
mitymouse

Reputation: 33

Printing database query response as json array/list in Karate

I am using DBUtils' readRows() method in Karate and receiving a response in the form of a list of maps which I save as a json variable called response. The data looks like this:

[
      {
        "ID": "001"
      },
      {
        "ID": "002"
      },
      {
        "ID": "003"
      }
]

The assertion works with

* match response[*].ID == ["001", "002", "003"]

but it doesn't print anything for

* print response[*].ID

I was expecting it would print the three id's ["001", "002", "003"]. Any idea why its not printing anything?

Upvotes: 1

Views: 1374

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58088

Do this:

* def output = $response[*].ID
* print output

Upvotes: 1

Related Questions