Product Solutions Support
Try MemSQL

JSON_SPLICE_<type>

This is a set of three JSON functions, which deletes the given element indexes from an array, and optionally splices the new values in.

Arrays are in the form:

[1, 2, 3]

Return Type

Examples

mysql> select json_splice_json('[1,2,3]', 2, 3, '[4,5,6]') as nested;
+---------------+
| nested        |
+---------------+
| [1,2,[4,5,6]] |
+---------------+

mysql> select json_splice_string('[1,2,3,4,5]', 2, 2, 'o', 'hai', '!') as ohai;
+-----------------------+
| ohai                  |
+-----------------------+
| [1,2,"o","hai","!",5] |
+-----------------------+

mysql> select json_splice_string('[1,2,3,4,5]', -1, 1) as pop;
+-----------+
| pop       |
+-----------+
| [1,2,3,4] |
+-----------+
Info

A JSON or Javascript null value is distinct from SQL NULL.

Was this article useful?