karate jsonObject[*].label and $jsonObject[*].label throws an error

Viewed 15

jsonObject :

[
   {
    "label": "Happy",
    "key": "478870b9-2d6012",
    "version": 1
  },
  {
    "label": "Face",
    "key": "478870b9-2d60698",
    "version": 3
  }
]

When i perform jsonObject[*].label and $jsonObject[*].label throws an error, Can someone please help!

I am expecting ["Happy","Face"]

1 Answers

This works for me:

* def jsonObject = 
"""
[
   {
    "label": "Happy",
    "key": "478870b9-2d6012",
    "version": 1
  },
  {
    "label": "Face",
    "key": "478870b9-2d60698",
    "version": 3
  }
]
"""
* def temp = $jsonObject[*].label
* match temp == ['Happy', 'Face']
Related