bag_remove_keys()

Removes keys and associated values from a dynamic property-bag.

Syntax

bag_remove_keys(bag, keys)

Arguments

  • bag: dynamic property-bag input.
  • keys: dynamic array includes keys to be removed from the input. Keys refer to the first level of the property bag. You can specify keys on the nested levels using JSONPath notation.

Returns

Returns a dynamic property-bag without specified keys and their values.

Example

datatable(input:dynamic)
[
    dynamic({'key1' : 123,     'key2': 'abc'}),
    dynamic({'key1' : 'value', 'key3': 42.0}),
]
| extend result=bag_remove_keys(input, dynamic(['key2', 'key4']))
input result
{
"key1": 123,
"key2": "abc"
}
{
"key1": 123
}
{
"key1": "value",
"key3": 42.0
}
{
"key1": "value",
"key3": 42.0
}

Remove inner properties of dynamic values using JSONPath notation

datatable(input:dynamic)
[
    dynamic({'key1': 123, 'key2': {'prop1' : 'abc', 'prop2': 'xyz'}, 'key3': [100, 200]}),
]
| extend result=bag_remove_keys(input, dynamic(['$.key2.prop1', 'key3']))
input result
{
"key1": 123,
"key2": {
"prop1": "abc",
"prop2": "xyz"
},
"key3": [
100,
200
]
}
{
"key1": 123,
"key2": {
"prop2": "xyz"
}
}