Syntax
Parameters
-
json_object_expr: the expression that represents the JSON object. The object can be a JSON column, or a JSON object that is produced by a JSON constructor function such as PARSE_JSON. -
json_path: one or more expressions that represent the paths to elements in the JSON object that should be removed. The value of each parameter is a string. For information about the JSON path syntax that is supported by the database, see Overview of JSON functions and operators.
Return value
Returns a JSON document with the specified paths removed.
- If a path does not exist in the JSON document, it is ignored.
- If an invalid path is provided, it is ignored.
- If all paths are invalid or non-existent, the original JSON document is returned unchanged.
Examples
Example 1: Remove a single key from a JSON object.Usage notes
- The
json_removefunction follows MySQL-compatible behavior. - Invalid JSON paths are silently ignored rather than causing errors.
- The function supports removing multiple paths in a single operation, which is more efficient than multiple separate operations.
- Currently, the function supports simple object key removal (e.g.,
$.key). Support for complex nested paths and array element removal may be limited in the current implementation.