12.18.1 JSON Function ReferenceJSON函数参考

Table 12.22 JSON FunctionsJSON函数

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

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

MySQL also supports pretty-printing of JSON values in an easy-to-read format, using the JSON_PRETTY() function. MySQL还支持使用JSON_pretty()函数以易于阅读的格式“漂亮地打印”JSON值。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. 您可以分别使用JSON_storage_SIZE()JSON_storage_FREE()来查看给定JSON值占用的存储空间以及剩余的额外存储空间。For complete descriptions of these functions, see Section 12.18.8, “JSON Utility Functions”.有关这些函数的完整描述,请参阅第12.18.8节,“JSON实用程序函数”