OBJECT_DELETE
Deletes specified keys from a JSON object and returns the modified object. If a specified key doesn't exist in the object, it is ignored.
Aliases
JSON_OBJECT_DELETE
Syntax
OBJECT_DELETE(<json_object>, <key1> [, <key2>, ...])
Parameters
Return Type
Returns a VARIANT containing the modified JSON object with specified keys removed.
Examples
Delete a single key:
SELECT OBJECT_DELETE('{"a":1,"b":2,"c":3}'::VARIANT, 'a');
-- Result: {"b":2,"c":3}
Delete multiple keys:
SELECT OBJECT_DELETE('{"a":1,"b":2,"d":4}'::VARIANT, 'a', 'c');
-- Result: {"b":2,"d":4}
Delete a non-existent key (key is ignored):
SELECT OBJECT_DELETE('{"a":1,"b":2}'::VARIANT, 'x');
-- Result: {"a":1,"b":2}