I'd like to insert this JSON value ["Chien", "Chat"] in a JSON, with MySQL8 built-in JSON functions. So I tried with this query but I didn't get the expected output:
UPDATE tasks SET outputFields = JSON_SET(outputFields, '$.checkbox', '["Chien","Chat"]') WHERE id = 6832
This query made this valid JSON:
{"key1": "value1", "key2": "value2", "key3": "value3", "checkbox": "[\"Chien\",\"Chat\"]"}
The expected value is:
{"key1": "value1", "key2": "value2", "key3": "value3", "checkbox": ["Chien","Chat"]}
Is there a function or a work arround for it?
Just use CAST function like this:
UPDATE tasks SET outputFields = JSON_SET(outputFields, '$.checkbox', cast('["Chien","Chat"]' as json)) WHERE id = 6832
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments