文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 55%

14.17.1 JSON 函数参考14.17.1 JSON Function Reference

表 14.22 JSON 函数Table 14.22 JSON Functions

名称Name 说明Description 已弃用Deprecated
-> 在评估路径后从 JSON 列返回值;等同于 JSON_EXTRACT()。Return value from JSON column after evaluating path; equivalent to JSON_EXTRACT().
->> 在评估路径并去掉结果引号后从 JSON 列返回值;等同于 JSON_UNQUOTE(JSON_EXTRACT())。Return value from JSON column after evaluating path and unquoting the result; equivalent to JSON_UNQUOTE(JSON_EXTRACT()).
JSON_ARRAY() 创建 JSON 数组Create JSON array
JSON_ARRAY_APPEND() 向 JSON 文档添加数据Append data to JSON document
JSON_ARRAY_INSERT() 插入到 JSON 数组中Insert into JSON array
JSON_CONTAINS() JSON 文档是否在路径中包含特定对象Whether JSON document contains specific object at path
JSON_CONTAINS_PATH() JSON 文档的路径中是否包含任何数据Whether JSON document contains any data at path
JSON_DEPTH() JSON 文档的最大深度Maximum depth of JSON document
JSON_EXTRACT() 从 JSON 文档返回数据Return data from JSON document
JSON_INSERT() 将数据插入到 JSON 文档中Insert data into JSON document
JSON_KEYS() 来自 JSON 文档的键数组Array of keys from JSON document
JSON_LENGTH() JSON 文档中的元素数量Number of elements in JSON document
JSON_MERGE() 合并 JSON 文档,保留重复键。JSON_MERGE_PRESERVE() 的已弃用同义词Merge JSON documents, preserving duplicate keys. Deprecated synonym for JSON_MERGE_PRESERVE() 是Yes
JSON_MERGE_PATCH() 合并 JSON 文档,替换重复键的值Merge JSON documents, replacing values of duplicate keys
JSON_MERGE_PRESERVE() 合并 JSON 文档,保留重复键Merge JSON documents, preserving duplicate keys
JSON_OBJECT() 创建 JSON 对象Create JSON object
JSON_OVERLAPS() 比较两个 JSON 文档,如果它们有任何键-值对或数组元素相同则返回 TRUE (1),否则返回 FALSE (0)Compares two JSON documents, returns TRUE (1) if these have any key-value pairs or array elements in common, otherwise FALSE (0)
JSON_PRETTY() 以人类可读的格式打印 JSON 文档Print a JSON document in human-readable format
JSON_QUOTE() 引用 JSON 文档Quote JSON document
JSON_REMOVE() 从 JSON 文档中删除数据Remove data from JSON document
JSON_REPLACE() 替换 JSON 文档中的值Replace values in JSON document
JSON_SCHEMA_VALID() 根据 JSON 模式验证 JSON 文档;如果文档符合模式返回 TRUE/1,否则返回 FALSE/0Validate JSON document against JSON schema; returns TRUE/1 if document validates against schema, or FALSE/0 if it does not
JSON_SCHEMA_VALIDATION_REPORT() 根据 JSON 模式验证 JSON 文档;以 JSON 格式返回验证结果报告,包括成功或失败以及失败原因Validate JSON document against JSON schema; returns report in JSON format on outcome on validation including success or failure and reasons for failure
JSON_SEARCH() JSON 文档中的值的路径Path to value within JSON document
JSON_SET() 将数据插入到 JSON 文档中Insert data into JSON document
JSON_STORAGE_FREE() 在 JSON 列值部分更新后释放的二进制表示中的空间Freed space within binary representation of JSON column value following partial update
JSON_STORAGE_SIZE() 用于存储 JSON 文档二进制表示的空间Space used for storage of binary representation of a JSON document
JSON_TABLE() 将 JSON 表达式中的数据作为关系表返回Return data from a JSON expression as a relational table
JSON_TYPE() JSON 值的类型Type of JSON value
JSON_UNQUOTE() 取消引用 JSON 值Unquote JSON value
JSON_VALID() JSON 值是否有效Whether JSON value is valid
JSON_VALUE() 从 JSON 文档中提取路径所指位置的值;将此值返回为 VARCHAR(512) 或指定类型Extract value from JSON document at location pointed to by path provided; return this value as VARCHAR(512) or specified type
MEMBER OF() 如果第一个操作数与作为第二个操作数传递的 JSON 数组中的任何元素匹配,则返回 true (1),否则返回 false (0)Returns true (1) if first operand matches any element of JSON array passed as second operand, otherwise returns false (0)

MySQL 支持两种聚合 JSON 函数 JSON_ARRAYAGG() 和 JSON_OBJECTAGG()。有关这些函数的描述,请参见 第 14.19 节,“聚合函数”。MySQL supports two aggregate JSON functions JSON_ARRAYAGG() and JSON_OBJECTAGG(). See Section 14.19, “Aggregate Functions”, for descriptions of these.

MySQL 还支持以易于阅读的格式“美化打印” JSON 值,可以使用 JSON_PRETTY() 函数。您可以使用 JSON_STORAGE_SIZE() 和 JSON_STORAGE_FREE() 分别查看给定 JSON 值占用多少存储空间,以及剩余多少空间可用于额外存储。有关这些函数的完整说明,请参见 第 14.17.8 节,“JSON 实用函数”。MySQL also supports “pretty-printing” of JSON values in an easy-to-read format, using the JSON_PRETTY() function. You can see how much storage space a given JSON value takes up, and how much space remains for additional storage, using JSON_STORAGE_SIZE() and JSON_STORAGE_FREE(), respectively. For complete descriptions of these functions, see Section 14.17.8, “JSON Utility Functions”.