Pratyush M
Pratyush M

Reputation: 11

valid json becomes invalid json when calling a javascript function

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

actual output -{pratyush=abc} expected output - {"pratyush":'abc'}

Upvotes: 1

Views: 43

Answers (1)

Babu Sekaran
Babu Sekaran

Reputation: 4239

use pretty to print it like JSON

karate.log(karate.pretty(x))

other than that it doesn't make it as invalid JSON

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

Upvotes: 1

Related Questions