In Karate, you can use the karate.remove
function with a JSON object to remove properties. Here's an example:
* def myObj = { name: 'John', age: 30, email: 'john@example.com' }
* def propertiesToRemove = ['email']
* karate.remove('myObj', propertiesToRemove)
In this example, the karate.remove
function is called with the name of the JSON object (myObj
) and an array of property names to remove (propertiesToRemove
). This will remove the email
property from the myObj
object.
The resulting object will be:
{ name: 'John', age: 30 }
Note that the original myObj
object remains unchanged. To update the object with the removed properties, you can assign the result of the karate.remove
function back to the original variable:
* myObj = karate.remove('myObj', propertiesToRemove)
Asked: 2022-08-28 11:00:00 +0000
Seen: 9 times
Last updated: Nov 20 '22