相关文章推荐
近视的桔子  ·  SELECT 下拉框 重复点击选项 ...·  4 周前    · 
飘逸的炒饭  ·  如何使用并发控制CCL规则_云数据库 ...·  3 周前    · 
想表白的面包  ·  什么是KV/KKV查询_智能开放搜索 ...·  3 周前    · 
稳重的冰淇淋  ·  深入解析Oracle数据库ORA-01427 ...·  2 周前    · 
茫然的黑框眼镜  ·  MISSING_AGGREGATION ...·  2 周前    · 
飘逸的煎鸡蛋  ·  PHP 表单 | 菜鸟教程·  1 年前    · 
高大的蟠桃  ·  【精选】北京大学吴华君课题组多组学数据分析方 ...·  1 年前    · 
博学的篮球  ·  Tellg函数和tellp函数 - 简书·  1 年前    · 
大力的勺子  ·  中文通用大模型综合性评测基准SuperCLU ...·  1 年前    · 
Code  ›  MySQL :: MySQL 8.4 Reference Manual :: 14.17.5 Functions That Return JSON Value Attributes
mysql select
https://dev.mysql.com/doc/refman/8.4/en/json-attribute-functions.html
温柔的槟榔
7 月前
Argument Handling by Spatial Functions
Functions That Create Geometry Values from WKT Values
Functions That Create Geometry Values from WKB Values
MySQL-Specific Functions That Create Geometry Values
Geometry Format Conversion Functions
Geometry Property Functions
General Geometry Property Functions
Point Property Functions
LineString and MultiLineString Property Functions
Polygon and MultiPolygon Property Functions
GeometryCollection Property Functions
Function which Configures Group Replication Primary
Functions which Configure the Group Replication Mode
Functions to Inspect and Configure the Maximum Consensus Instances of a Group
Functions to Inspect and Set the Group Replication Communication Protocol Version
Functions to Set and Reset Group Replication Member Actions
Functions Used with Global Transaction Identifiers (GTIDs)
Asynchronous Replication Channel Failover Functions
Position-Based Synchronization Functions
Returns the maximum depth of a JSON document. Returns NULL if the argument is NULL . An error occurs if the argument is not a valid JSON document. An empty array, empty object, or scalar value has depth 1. A nonempty array containing only elements of depth 1 or nonempty object containing only member values of depth 1 has depth 2. Otherwise, a JSON document has depth greater than 2.

mysql> SELECT JSON_DEPTH('{}'), JSON_DEPTH('[]'), JSON_DEPTH('true');
+------------------+------------------+--------------------+
| JSON_DEPTH('{}') | JSON_DEPTH('[]') | JSON_DEPTH('true') |
+------------------+------------------+--------------------+
|                1 |                1 |                  1 |
+------------------+------------------+--------------------+
mysql> SELECT JSON_DEPTH('[10, 20]'), JSON_DEPTH('[[], {}]');
+------------------------+------------------------+
| JSON_DEPTH('[10, 20]') | JSON_DEPTH('[[], {}]') |
+------------------------+------------------------+
|                      2 |                      2 |
+------------------------+------------------------+
mysql> SELECT JSON_DEPTH('[10, {"a": 20}]');
+-------------------------------+
| JSON_DEPTH('[10, {"a": 20}]') |
+-------------------------------+
|                             3 |
+-------------------------------+
  • JSON_LENGTH( json_doc [, path ]) Returns the length of a JSON document, or, if a path argument is given, the length of the value within the document identified by the path. Returns NULL if any argument is NULL or the path argument does not identify a value in the document. An error occurs if the json_doc argument is not a valid JSON document or the path argument is not a valid path expression. The length of a document is determined as follows: The length of a scalar is 1. The length of an array is the number of array elements. The length of an object is the number of object members. The length does not count the length of nested arrays or objects.

    mysql> SELECT JSON_LENGTH('[1, 2, {"a": 3}]');
    +---------------------------------+
    | JSON_LENGTH('[1, 2, {"a": 3}]') |
    +---------------------------------+
    |                               3 |
    +---------------------------------+
    mysql> SELECT JSON_LENGTH('{"a": 1, "b": {"c": 30}}');
    +-----------------------------------------+
    | JSON_LENGTH('{"a": 1, "b": {"c": 30}}') |
    +-----------------------------------------+
    |                                       2 |
    +-----------------------------------------+
    mysql> SELECT JSON_LENGTH('{"a": 1, "b": {"c": 30}}', '$.b');
    +------------------------------------------------+
    | JSON_LENGTH('{"a": 1, "b": {"c": 30}}', '$.b') |
    +------------------------------------------------+
    |                                              1 |
    +------------------------------------------------+
  • JSON_TYPE( json_val ) Returns a utf8mb4 string indicating the type of a JSON value. This can be an object, an array, or a scalar type, as shown here:

    mysql> SET @j = '{"a": [10, true]}';
    mysql> SELECT JSON_TYPE(@j);
    +---------------+
    | JSON_TYPE(@j) |
    +---------------+
    | OBJECT        |
    +---------------+
    mysql> SELECT JSON_TYPE(JSON_EXTRACT(@j, '$.a'));
    +------------------------------------+
    | JSON_TYPE(JSON_EXTRACT(@j, '$.a')) |
    +------------------------------------+
    | ARRAY                              |
    +------------------------------------+
    mysql> SELECT JSON_TYPE(JSON_EXTRACT(@j, '$.a[0]'));
    +---------------------------------------+
    | JSON_TYPE(JSON_EXTRACT(@j, '$.a[0]')) |
    +---------------------------------------+
    | INTEGER                               |
    +---------------------------------------+
    mysql> SELECT JSON_TYPE(JSON_EXTRACT(@j, '$.a[1]'));
    +---------------------------------------+
    | JSON_TYPE(JSON_EXTRACT(@j, '$.a[1]')) |
    +---------------------------------------+
    | BOOLEAN                               |
    +---------------------------------------+

    JSON_TYPE() returns NULL if the argument is NULL :

    mysql> SELECT JSON_TYPE(NULL);
    +-----------------+
    | JSON_TYPE(NULL) |
    +-----------------+
    | NULL            |
    +-----------------+

    An error occurs if the argument is not a valid JSON value:

    mysql> SELECT JSON_TYPE(1);
    ERROR 3146 (22032): Invalid data type for JSON data in argument 1
    to function json_type; a JSON string or JSON type is required.

    For a non- NULL , non-error result, the following list describes the possible JSON_TYPE() return values: Purely JSON types: OBJECT : JSON objects ARRAY : JSON arrays BOOLEAN : The JSON true and false literals NULL : The JSON null literal Numeric types: INTEGER : MySQL TINYINT , SMALLINT , MEDIUMINT and INT and BIGINT scalars DOUBLE : MySQL DOUBLE FLOAT scalars DECIMAL : MySQL DECIMAL and NUMERIC scalars Temporal types: DATETIME : MySQL DATETIME and TIMESTAMP scalars DATE : MySQL DATE scalars TIME : MySQL TIME scalars String types: STRING : MySQL utf8mb3 character type scalars: CHAR , VARCHAR , TEXT , ENUM , and Binary types: BLOB : MySQL binary type scalars including BINARY , VARBINARY , BLOB , and All other types: OPAQUE (raw bits) Returns 0 or 1 to indicate whether a value is valid JSON. Returns NULL if the argument is NULL .

    mysql> SELECT JSON_VALID('{"a": 1}');
    +------------------------+
    | JSON_VALID('{"a": 1}') |
    +------------------------+
    |                      1 |
    +------------------------+
    mysql> SELECT JSON_VALID('hello'), JSON_VALID('"hello"');
    +---------------------+-----------------------+
    | JSON_VALID('hello') | JSON_VALID('"hello"') |
    +---------------------+-----------------------+
    |                   0 |                     1 |
    +---------------------+-----------------------+
  •  
    推荐文章
    近视的桔子  ·  SELECT 下拉框 重复点击选项 change事件无法再次触发的问题
    4 周前
    飘逸的炒饭  ·  如何使用并发控制CCL规则_云数据库 RDS(RDS)-阿里云帮助中心
    3 周前
    想表白的面包  ·  什么是KV/KKV查询_智能开放搜索 OpenSearch(Open Search)-阿里云帮助中心
    3 周前
    稳重的冰淇淋  ·  深入解析Oracle数据库ORA-01427错误:单行子查询返回多行的问题与解决办法
    2 周前
    茫然的黑框眼镜  ·  MISSING_AGGREGATION 错误条件 - Azure Databricks | Microsoft Learn
    2 周前
    飘逸的煎鸡蛋  ·  PHP 表单 | 菜鸟教程
    1 年前
    高大的蟠桃  ·  【精选】北京大学吴华君课题组多组学数据分析方向博士后和技术员招聘启示_刘永鑫Adam的博客-CSDN博客
    1 年前
    博学的篮球  ·  Tellg函数和tellp函数 - 简书
    1 年前
    大力的勺子  ·  中文通用大模型综合性评测基准SuperCLUE正式发布 中文通用大模型综合性评测基准SuperCLUE正式发布。SuperCLUE: A Benchmark for Found...
    1 年前
    今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
    删除内容请联系邮箱 2879853325@qq.com
    Code - 代码工具平台
    © 2024 ~ 沪ICP备11025650号