(三)修改JSON的函数
JSON_ARRAY_APPEND() #数组尾部追加元素
JSON_ARRAY_INSERT() #在数组的指定位置插入元素
JSON_REPLACE() #替换文档中指定位置的元素
JSON_SET() #给文档中指定位置的元素设置新值,如果元素不存在,则进行插入
JSON_MERGEPRESERVE() #将两个文档合并
JSON_REMOVE() #删除文档中指定位置的元素
1.JSON_ARRAY_APPEND()
SELECT JSON_ARRAY_APPEND('{"a":1,"b": [2, 3],"c":4}',"$.b","1") ,JSON_ARRAY_APPEND('["a",["b","c"],"d"]','$[1][0]','1')
2. JSON_ARRAY_INSERT()
SELECT JSON_ARRAY_INSERT('["a",["b","c"],"d"]','$[0]',"1"),JSON_ARRAY_INSERT('["a",["b","c"],"d"]','$[1]',"1")
3.JSON_REPALCE()
SELECT JSON_REPLACE('["a",["b","c"],"d"]','$[0]',"1",'$[1]',"2")
4. JSON_SET()
SELECT JSON_SET('{"a":1,"b":[2,3],"c":4}','$.a',"10",'$.d',"20")
5. JSON_MERGE_PRESERVE()
SELECT JSON_MERGE_PRESERVE('[1,2]','[3,4]')
6.JSON_REMOVE()
SELECT JSON_REMOVE('[1,2,3,4]','$[1]','$[2]')