Create JSON Object and Array
suggest changeJSON_OBJECT creates JSON Objects:
SELECT JSON_OBJECT('key1',col1 , 'key2',col2 , 'key3','col3') as myobj;
JSON_ARRAY creates a JSON array:
SELECT JSON_ARRAY(col1,col2,'col3') as myarray;
Note: myobj's key key3 and myarray's element 2 (JSON arrays are zero-based) are the fixed string "col3", not a column.
Also mixed JSON data:
SELECT JSON_OBJECT("opening","Sicilian", "variations",JSON_ARRAY("pelikan","dragon","najdorf") ) as mymixed ;
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents