This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git


The following commit(s) were added to refs/heads/master by this push:
     new c3bf5b4a142 [doc](function)  json_valid input json value (#2850)
c3bf5b4a142 is described below

commit c3bf5b4a1428d46c2ece43ff72b7f7b66c55ec3b
Author: Mryange <[email protected]>
AuthorDate: Wed Feb 11 03:18:08 2026 +0800

    [doc](function)  json_valid input json value (#2850)
    
    ## Versions
    
    - [x] dev
    - [ ] 3.0
    - [ ] 2.1
    - [ ] 2.0
    
    ## Languages
    
    - [x] Chinese
    - [x] English
    
    ## Docs Checklist
    
    - [ ] Checked by AI
    - [ ] Test Cases Built
---
 .../scalar-functions/json-functions/json-valid.md  | 102 +++++++++++++--------
 .../scalar-functions/json-functions/json-valid.md  |  42 +++++++--
 2 files changed, 94 insertions(+), 50 deletions(-)

diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-valid.md 
b/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-valid.md
index 22d0ec8c346..0e0e97c8063 100644
--- 
a/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-valid.md
+++ 
b/docs/sql-manual/sql-functions/scalar-functions/json-functions/json-valid.md
@@ -8,58 +8,80 @@
 
 ## Description
 
-The JSON_VALID function returns 0 or 1 to indicate whether the input is a 
valid JSON. If the input is NULL, it returns NULL.
+The JSON_VALID function is used to validate whether the input is valid JSON 
format. This function accepts String type or JSON type input and validates the 
JSON format.
 
 ## Syntax
 
 ```sql
-JSON_VALID( <str> )
-
+JSON_VALID(<str>)
+JSON_VALID(<json>)
 ```
 
-Required Parameters
-| Parameter | Description |
-|------|------|
-| `<str>` | The input string in JSON format to be parsed. |
-
-## Alias
-
-- JSONB_VALID
-
-## Examples
+## Parameters
 
-1. Valid JSON string
+- `<str>`: String type, the JSON format string to be validated
+- `<json>`: JSON type, the JSON value to be validated
 
-```sql
-SELECT json_valid('{"k1":"v31","k2":300}');
-+-------------------------------------+
-| json_valid('{"k1":"v31","k2":300}') |
-+-------------------------------------+
-|                                   1 |
-+-------------------------------------+
+## Return Values
 
-```
+- `1`: When the input is valid JSON format
+- `0`: When the input is not valid JSON format
+- `NULL`: When the input parameter is NULL
 
-2. Invalid JSON string
+## Notes
 
-```sql
-SELECT json_valid('invalid json');
-+----------------------------+
-| json_valid('invalid json') |
-+----------------------------+
-|                          0 |
-+----------------------------+
+The support for JSON type parameters is to avoid potential issues that might 
occur with implicit type conversion (JSON to String) when passing a JSON 
column. Typically, data stored in JSON type columns is valid JSON data, so 
calling JSON_VALID on a JSON type parameter usually returns 1.
 
-```
+## Alias
 
-3. NULL 参数
+- JSONB_VALID
 
-```sql
-SELECT json_valid(NULL);
-+------------------+
-| json_valid(NULL) |
-+------------------+
-|             NULL |
-+------------------+
+## Examples
 
-```
+1. Validate a valid JSON string
+    ```sql
+    SELECT json_valid('{"k1":"v31","k2":300}');
+    ```
+    ```text
+    +-------------------------------------+
+    | json_valid('{"k1":"v31","k2":300}') |
+    +-------------------------------------+
+    |                                   1 |
+    +-------------------------------------+
+    ```
+
+2. Validate an invalid JSON string
+    ```sql
+    SELECT json_valid('invalid json');
+    ```
+    ```text
+    +----------------------------+
+    | json_valid('invalid json') |
+    +----------------------------+
+    |                          0 |
+    +----------------------------+
+    ```
+
+3. Validate NULL parameter
+    ```sql
+    SELECT json_valid(NULL);
+    ```
+    ```text
+    +------------------+
+    | json_valid(NULL) |
+    +------------------+
+    |             NULL |
+    +------------------+
+    ```
+
+4. Validate JSON type parameter
+    ```sql
+    SELECT json_valid(cast('{"k1":"v31","k2":300}' as json));
+    ```
+    ```text
+    +----------------------------------------------------+
+    | json_valid(cast('{"k1":"v31","k2":300}' as json)) |
+    +----------------------------------------------------+
+    |                                                  1 |
+    +----------------------------------------------------+
+    ```
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-valid.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-valid.md
index 04a5a04df24..c2216d0e461 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-valid.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-valid.md
@@ -8,21 +8,33 @@
 
 ## 描述
 
-JSON_VALID 函数用以判断字符串是否为有效的 JSON 字符串, 如果参数是 NULL 则返回 NULL。
+JSON_VALID 函数用于验证输入是否为有效的 JSON 格式。该函数可以接受 String 类型或 JSON 类型的输入,对 JSON 格式进行验证。
 
 ## 语法
 
 ```sql
-JSON_VALID( <str> )
+JSON_VALID(<str>)
+JSON_VALID(<json>)
 ```
 
-## 必选参数
-- `<str>` String 类型,需要判断的 JSON 格式字符串。
+## 参数说明
 
+- `<str>`: String 类型,需要验证的 JSON 格式字符串
+- `<json>`: JSON 类型,需要验证的 JSON 值
 
-## 举例
+## 返回值
 
-1. 正常 JSON 字符串
+- `1`:当输入是有效的 JSON 格式时
+- `0`:当输入不是有效的 JSON 格式时
+- `NULL`:当输入参数为 NULL 时
+
+## 注意事项
+
+支持 JSON 类型参数的原因是避免当传入 JSON 列时发生隐式类型转换(JSON 转 String)可能导致的问题。通常情况下,JSON 
类型的列中存储的都是有效的 JSON 数据,所以对 JSON 类型参数调用 JSON_VALID 通常返回 1。
+
+## 示例
+
+1. 验证有效的 JSON 字符串
     ```sql
     SELECT json_valid('{"k1":"v31","k2":300}');
     ```
@@ -32,10 +44,9 @@ JSON_VALID( <str> )
     +-------------------------------------+
     |                                   1 |
     +-------------------------------------+
-    1 row in set (0.02 sec)
     ```
 
-2. 无效的 JSON 字符串
+2. 验证无效的 JSON 字符串
     ```sql
     SELECT json_valid('invalid json');
     ```
@@ -45,10 +56,9 @@ JSON_VALID( <str> )
     +----------------------------+
     |                          0 |
     +----------------------------+
-
     ```
 
-3. NULL 参数
+3. 验证 NULL 参数
     ```sql
     SELECT json_valid(NULL);
     ```
@@ -58,4 +68,16 @@ JSON_VALID( <str> )
     +------------------+
     |             NULL |
     +------------------+
+    ```
+
+4. 验证 JSON 类型参数
+    ```sql
+    SELECT json_valid(cast('{"k1":"v31","k2":300}' as json));
+    ```
+    ```text
+    +----------------------------------------------------+
+    | json_valid(cast('{"k1":"v31","k2":300}' as json)) |
+    +----------------------------------------------------+
+    |                                                  1 |
+    +----------------------------------------------------+
     ```
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to