用空字符串替换null

时间:2020-07-17 08:29:34

标签: karate

我想用空字符串替换json中的所有空值,然后比较2个json数组。

例如 json1: [{ “ address01”:“ address1”, “ address02”:“ address2”, “ address03”:空 }, { “ address01”:“ address1”, “ address02”:null, “ address03”:空 } ]

json2: [{ “ address01”:“ address1”, “ address02”:“ address2”, “ address03”:“” }, { “ address01”:“ address1”, “ address02”:“”, “ address03”:“” } ]

1 个答案:

答案 0 :(得分:0)

尝试一下:

* def fun = function(x) { karate.forEach(x, function(k, v) { if (!v) x[k] = '' }); return x }
* def temp = karate.map(json1, fun)