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 where a dot indicates a 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 the nth element of a list, so a valid path would be "foo.7.bar" which indicates that you want to delete the "bar" key/value pair on the 7th element of the list of objects at the "foo" key.

This dot-delimited path is simple and powerful, but it doesn't work in all cases:  it may not work if a) your key names include dots within them, or b) 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 will be treated as a single key (no attempts to interpret numbers or dots).  For example, if object is {"a":"one", "b.foo":{ "7":"bar", "8":"baz"}}, you'll need to set path to be a list (using the type dropdown) with the first item "b.foo" and the second item "7" if you want to get the output {"a":"one", "b.foo":{ "8":"baz"}}

See Also

Functions in Workflows

About the elements of Okta Workflows