I want to delete a key from JSON. I found two examples shared by @Peter Thomas. I tried both and unfortunately, none worked.
Example 1
* def json = { a: 1, b: 2 }
* def key = 'b'
* if (true) karate.remove('json', key)
* match json == { a: 1 }
Error javascript evaluation failed: if (true) karate.remove('json', key), unexpected path: b
Example 2
* def json = { a: 1, b: 2 }
* def key = 'b'
* if (true) delete json[key]
* match json == { a: 1 }
Error actual: {a=1, b=2}, expected: {a=1}, reason: actual value has 1 more key(s) than expected: {b=2}