2

New to Karate, and JSON, for that matter, but I've got a variable like:

response {
  entries {
    products [
      {
        names [
          "Peter Parker",
          "Tony Stark",
          "Captain America"
        ]
      },
      {
        names [
          "Thomas Tinker",
          "Jimmy Johnson",
          "Mama Martha"
        ]
      }
    ]
  }
}

match each response.entries.products[*].names returns a list like:

["Peter Parker","Tony Stark","Captain America","Thomas Tinker","Jimmy Johnson","Mama Martha"]

But I'd like to assign that output to a variable, such as:

* def variable = response.entries.products[*].names

that would hold a similar value. When I use the above line, I get the following error:

Expected an operand but found *

Is it possible to achieve that, or something similar? If so, how?

Thanks!

1 Answer 1

1

Yes, there is syntax for that:

* def variable = $response.entries.products[*].names

Read the docs: https://github.com/intuit/karate#get

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.