Functions That Modify JSON Values following values to the right. If a path identifies an array position past the end of an array, the value is inserted at the end of the array. mysql>  SET @j = ’["a", {"b": [1, 2]}, [3, 4]]’; mysql>  SELECT JSON_ARRAY_INSERT(@j, ’$[1]’, ’x’); +------------------------------------+ | JSON_ARRAY_INSERT(@j, ’$[1]’, ’x’) | +------------------------------------+ | ["a", "x", {"b": [1, 2]}, [3, 4]] | +------------------------------------+ mysql>  SELECT JSON_ARRAY_INSERT(@j, ’$[100]’, ’x’); +--------------------------------------+ | JSON_ARRAY_INSERT(@j, ’$[100]’, ’x’) | +--------------------------------------+ | ["a", {"b": [1, 2]}, [3, 4], "x"] | +--------------------------------------+ mysql>  SELECT JSON_ARRAY_INSERT(@j, ’$[1].b[0]’, ’x’); +-----------------------------------------+ | JSON_ARRAY_INSERT(@j, ’$[1].b[0]’, ’x’) | +-----------------------------------------+ | ["a", {"b": ["x", 1, 2]}, [3, 4]] | +-----------------------------------------+ mysql>  SELECT JSON_ARRAY_INSERT(@j, ’$[2][1]’, ’y’); +---------------------------------------+ | JSON_ARRAY_INSERT(@j, ’$[2][1]’, ’y’) | +---------------------------------------+ | ["a", {"b": [1, 2]}, [3, "y", 4]] | +---------------------------------------+ mysql>  SELECT JSON_ARRAY_INSERT(@j, ’$[0]’, ’x’, ’$[2][1]’, ’y’); +----------------------------------------------------+ | JSON_ARRAY_INSERT(@j, ’$[0]’, ’x’, ’$[2][1]’, ’y’) | +----------------------------------------------------+ | ["x", "a", {"b": [1, 2]}, [3, 4]] | +----------------------------------------------------+ Earlier modifications affect the positions of the following elements in the array, so subsequent paths in the same  JSON_ARRAY_INSERT()  call should take this into account. In the final example, the second path inserts nothing because the path no longer matches anything after the first insert. • JSON_INSERT( json_doc ,  path ,  val [,  path ,  val ] ...) Inserts data into a JSON document and returns the result. 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. 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. A path-value pair for an existing path in the document is ignored and does not overwrite the existing document value. A path-value pair for a nonexisting path in the document adds the value to the document if the path identifies one of these types of values: Otherwise, a path-value pair for a nonexisting path in the document is ignored and has no effect. For a comparison of  JSON_INSERT() ,  JSON_REPLACE() , and  JSON_SET() , see the discussion of JSON_SET() . •A position past the end of an existing array. The array is extended with the new value. If the existing value is not an array, it is autowrapped as an array, then extended with the new value. •A member not present in an existing object. The member is added to the object and associated with the new value. 2365