Karate 如何在空手道中从foor循环打印多个值

Karate 如何在空手道中从foor循环打印多个值,karate,Karate,我有一个json,看起来像这样 { "name": "xyz.json", "fileSize": "391 B", "timestamp": "2020-06-22 12:03:00 GMT", "tag": "abc1" }, { "name": "abc.json", "fileSi

我有一个json,看起来像这样

{
"name": "xyz.json",
"fileSize": "391 B",
"timestamp": "2020-06-22 12:03:00 GMT",
"tag": "abc1"
},
{
"name": "abc.json",
"fileSize": "391 B",
"timestamp": "2020-06-22 12:03:01 GMT",
"tag": "abc2"
},
我有755条类似于上面的json记录。现在,从我编写的上述json中获取时间戳

* def myfun2 = 
"""
function(arg){
           
return arg[754].timestamp;
}
}
            
"""
* def numos = call myfun2 data
Then print 'numos--',numos
这将打印json中的最后一个时间戳

现在,我尝试了一些类似的方法来打印所有754个时间戳值

* def myfun2 = 
        
"""
function(arg){
           
for(i = 0; i <= arg.length; i++)
{
return arg[i].timestamp;

}
}
"""
* def numos = call myfun2 data
Then print 'numos--',numos
*def myfun2=
"""
函数(arg){

对于(i=0;i您能否使用推荐的方法进行循环:


请使用推荐的方法进行循环:

karate.forEach(items, function(x){ karate.log('item is', x) })