调用javascript函数时,有效json变为无效json

时间:2019-03-17 18:40:17

标签: karate

* def xyz = 'abc'
* def abc = {"pratyush" : '#(xyz)'}
* def editJson =
"""
function(s)
{
var x = s.x
karate.log(x)
}
"""
* def p = call editJson ({"x" :abc})

实际输出-{pratyush = abc} 预期的输出-{“ pratyush”:'abc'}

1 个答案:

答案 0 :(得分:1)

使用漂亮的样式像JSON

一样打印
karate.log(karate.pretty(x))

除此之外,它不会使它成为无效的JSON

* def editJson =
"""
function(s)
{
var x = s.x
return x;
}
"""
* def p = call editJson ({"x" :abc})
* print p
# {"pratyush":'abc'}