Home > Database > Mysql Tutorial > How MySQL uses JSON functions

How MySQL uses JSON functions

王林
Release: 2023-06-02 16:34:04
forward
1283 people have browsed it

JSON function (only supported in version 5.7)

Command: json_object (function)

Function: Convert json string

Application scenarios: Specify data conversion json string

Example:

mysql> select json_object("name","andyqian","database","MySQL");
+---------------------------------------------------+
| json_object("name","andyqian","database","MySQL") |
+---------------------------------------------------+
| {"name": "andyqian", "database": "MySQL"}  |
+---------------------------------------------------+
1 row in set (0.00 sec)
Copy after login

Including json_array:

mysql> select json_array("name","andyqian","database","MySQL");
+--------------------------------------------------+
| json_array("name","andyqian","database","MySQL") |
+--------------------------------------------------+
| ["name", "andyqian", "database", "MySQL"] |
+--------------------------------------------------+
1 row in set (0.00 sec)
Copy after login

json_valid() to determine whether it is a json string:

select json_valid('{"name": "andyqian", "database": "MySQL"}');
Copy after login

It is 1 when it is a valid json string.

Invalid json string is 0.

There are many other methods, so I won’t demonstrate them one by one.

The above is the detailed content of How MySQL uses JSON functions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template