what's the meaning of the word "Json document" in mysql?

bmxbmx3 :

I have read the usage of json in mysql documentation,but I still don't understand the meaning of the word "JSON document",does it mean "json data type" or anything else?I have searched the almost entire documentation for this word but however can't find any explanation about it.

Bill Karwin :

A JSON document is a string, which conforms to the JSON format.

Basically, if JSON_VALID(string) returns true, then it's a JSON document.

Example: In JSON format, you can make an array of strings, but the strings must individually be quoted, or else it's not valid JSON.

mysql> select JSON_VALID('[words, must, be, quoted]');
+-----------------------------------------+
| JSON_VALID('[words, must, be, quoted]') |
+-----------------------------------------+
|                                       0 |
+-----------------------------------------+
1 row in set (0.00 sec)

mysql> select JSON_VALID('["words", "must", "be", "quoted"]');
+-------------------------------------------------+
| JSON_VALID('["words", "must", "be", "quoted"]') |
+-------------------------------------------------+
|                                               1 |
+-------------------------------------------------+

If it isn't valid JSON, then it isn't a "JSON document." If it isn't a JSON document, then a column of the JSON data type won't accept it, and none of MySQL's JSON functions will work.

There are of course other syntax rules for JSON format. See https://www.json.org/ for a specification.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=386112&siteId=1