Karate 空手道-从json中选择一个随机元素

Karate 空手道-从json中选择一个随机元素,karate,Karate,每次运行代码时,我都需要从下面的示例json中选择任意随机值。我怎样才能在空手道中做到这一点?我需要得到任何随机值,并在另一个功能文件中使用 def myJson = """ { "sampleJson": { "random1": "1", "random2": "2", "random3": "3", "random4": "4", "random5": "5" } } """ 另

每次运行代码时,我都需要从下面的示例json中选择任意随机值。我怎样才能在空手道中做到这一点?我需要得到任何随机值,并在另一个功能文件中使用

def myJson = 
"""
{
      "sampleJson": {
        "random1": "1",
        "random2": "2",
        "random3": "3",
        "random4": "4",
        "random5": "5"
      }
  }
"""
另请参阅:

到目前为止你试过什么?
* def random = function(max){ return Math.floor(Math.random() * max) + 1 }
* def myJson = 
"""
{
  "sampleJson": {
    "random1": "1",
    "random2": "2",
    "random3": "3",
    "random4": "4",
    "random5": "5"
  }
}
"""
* def key = 'random' + random(5)
* def result = myJson.sampleJson[key]
* print result