How to set a JSON value with JSON_SET MySQL function?

Julien

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?

Julien

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.

edited at
0

Comments

0 comments
Login to comment

Related

How to implement JSON_SET() in jOOQ for MySQL 8

MySQL JSON_SET() to work with empty arrays

MySQL JSON - How to use JSON_SET on all elements of a matched path?

mysql JSON_SET can't insert into column with NULL value(5.7+)

Correct syntax for MYSQL query to JSON_SET in Node

Migration - How to set default value for json? (MySQL)

Alternative of wildcard in JSON_SET in mariadb

Mysql set default value to a json type column

How to set value to JSON to based on @value

How to pass a set of json data in javascript function?

AMBARI + how to set value in json REST API

How to set multiline string as value to json object

how to set a hstore value in rails from json

How to set a default value for an object in json serialisable?

React: how to set up JSON value in defaultProps?

How to set a dynamic value for a json array in Karate

how to set json attribute using const value

How to SET a variable value in a function?

How to set default value in function

how to set value in getJSON function?

how to set value of attribute in a class and convert it into json using lift json

How to decode json and set value in json to php available ?

Set Textarea value to text or json of data properly in a function

json_set returns desired result (in SQLITE Browser) but does not update the table

How to set default value of a textbox from a jQuery function with a value from MySQL array?

How to read JSON value in MySQL

Set enumarated value in JSON schema

Set JSON Input value Dynamic

Powershell: Trying to set value in json

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    pump.io port in URL

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  14. 14

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  15. 15

    How to use merge windows unallocated space into Ubuntu using GParted?

  16. 16

    flutter: dropdown item programmatically unselect problem

  17. 17

    Pandas - check if dataframe has negative value in any column

  18. 18

    Nuget add packages gives access denied errors

  19. 19

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  20. 20

    Generate random UUIDv4 with Elm

  21. 21

    Client secret not provided in request error with Keycloak

HotTag

Archive