Outdated Version

You are viewing an older version of this section. View current production version.

JSON_DELETE_KEY

Removes a named key and value from a JSON map. Maps are in the form:

{"a": 1, "b": 2, "c": 3}
JSON_DELETE_KEY(json, keyname)

Arguments

  • json: a valid JSON array, or the name of a JSON column
  • keyname: the key to delete

Return Type

  • The complete array including the new element.
  • SQL NULL if json is not a valid JSON array.

Examples

mysql> select json_delete_key('{"a": 1, "b": 2, "c": 3}', 'a') as del;
+---------------+
| del           |
+---------------+
| {"b":2,"c":3} |
+---------------+

mysql> select json_delete_key('{"a": 1, "b": 2, "c": 3}', 'z') as nochange;
+---------------------+
| nochange            |
+---------------------+
| {"a":1,"b":2,"c":3} |
+---------------------+