Unset

Deletes a key/value pair from an object.

Input Fields

  • object: the object to delete the key/value pair from

  • path: the key to delete; either a top level key name, a dot-delimited path to a subkey, or a list of key names. (see examples below)

Output Fields

  • output: the new object

Examples

For the simple case where you want to delete a top-level key, just provide the key name as the path. For instance, if the object is {"foo":1, "bar":2} and path is foo, then output will be {"bar":2}.

A path can also be used to specify a key within a sub-object, using a dot to indicate the sub-object. For example, if object is {"a":"one", "b":{ "foo":1, "bar":2}} and path is b.foo, then output is {"a":"one", "b":{ "bar":2}}

You can also use a number to indicate any element of a list, so a valid path would be foo.7.bar to indicate that you want to delete the bar key/value pair on the 7th element of the list of objects found in the foo key.

This dot-delimited path is simple and powerful, but it may not work if your key names include dots, or your key names are numbers. In that case, you can control the path explicitly by using a list of text. Each item in the list is treated as a single key, without interpret numbers or dots. For example, if object is {"a":"one", "b.foo":{ "7":"bar", "8":"baz"}}, you need to set path to be a list using the type dropdown and specifying the first item as b.foo and the second item as 7 to get the output as {"a":"one", "b.foo":{ "8":"baz"}}

Related topics

Functions in Workflows

Workflow elements