If a path selects a scalar or object value, that value is autowrapped within an array and the new value is added to that array. Pairs for which the path does not identify any value in the JSON document are ignored. 

mysql> SET @j = ’["a", ["b", "c"], "d"]’; mysql> SELECT JSON_ARRAY_APPEND(@j, ’$[1]’, 1); +----------------------------------+ | JSON_ARRAY_APPEND(@j, ’$[1]’, 1) | +----------------------------------+ | ["a", ["b", "c", 1], "d"] | +----------------------------------+ mysql> SELECT JSON_ARRAY_APPEND(@j, ’$[0]’, 2); +----------------------------------+ | JSON_ARRAY_APPEND(@j, ’$[0]’, 2) | +----------------------------------+ | [["a", 2], ["b", "c"], "d"] | +----------------------------------+ mysql> SELECT JSON_ARRAY_APPEND(@j, ’$[1][0]’, 3); +-------------------------------------+ | JSON_ARRAY_APPEND(@j, ’$[1][0]’, 3) | +-------------------------------------+ | ["a", [["b", 3], "c"], "d"] | +-------------------------------------+ mysql> SET @j = ’{"a": 1, "b": [2, 3], "c": 4}’; mysql> SELECT JSON_ARRAY_APPEND(@j, ’$.b’, ’x’); +------------------------------------+ | JSON_ARRAY_APPEND(@j, ’$.b’, ’x’) | +------------------------------------+ | {"a": 1, "b": [2, 3, "x"], "c": 4} | +------------------------------------+ mysql> SELECT JSON_ARRAY_APPEND(@j, ’$.c’, ’y’); +--------------------------------------+ | JSON_ARRAY_APPEND(@j, ’$.c’, ’y’) | +--------------------------------------+ | {"a": 1, "b": [2, 3], "c": [4, "y"]} | +--------------------------------------+ mysql> SET @j = ’{"a": 1}’; mysql> SELECT JSON_ARRAY_APPEND(@j, ’$’, ’z’); +---------------------------------+ | JSON_ARRAY_APPEND(@j, ’$’, ’z’) | +---------------------------------+ | [{"a": 1}, "z"] | +---------------------------------+ 

In MySQL 5.7, this function was named JSON_APPEND() . That name is no longer supported in MySQL 8.0. 

• JSON_ARRAY_INSERT( json_doc , path , val [, path , val ] ...) 

Updates a JSON document, inserting into an array within the document and returning the modified document. Returns NULL  if any argument is NULL . An error occurs if the json_doc  argument is not a valid JSON document or any path  argument is not a valid path expression or contains a *  or ** wildcard or does not end with an array element identifier. 

The path-value pairs are evaluated left to right. The document produced by evaluating one pair becomes the new value against which the next pair is evaluated. 

Pairs for which the path does not identify any array in the JSON document are ignored. If a path identifies an array element, the corresponding value is inserted at that element position, shifting any 

