This is a read-only copy of the MariaDB Knowledgebase generated on 2024-05-01. For the latest, interactive version please visit https://mariadb.com/kb/.

JSON_INSERT

Syntax

JSON_INSERT(json_doc, path, val[, path, val] ...)

Description

Inserts data into a JSON document, returning the resulting document or NULL if either of the json_doc or path arguments are null.

An error will occur if the JSON document is invalid, or if any of the paths are invalid or contain a * or ** wildcard.

JSON_INSERT can only insert data while JSON_REPLACE can only update. JSON_SET can update or insert data.

Examples

SET @json = '{ "A": 0, "B": [1, 2]}';

SELECT JSON_INSERT(@json, '$.C', '[3, 4]');
+--------------------------------------+
| JSON_INSERT(@json, '$.C', '[3, 4]')  |
+--------------------------------------+
| { "A": 0, "B": [1, 2], "C":"[3, 4]"} |
+--------------------------------------+

See Also

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.