yiguolei commented on code in PR #2548:
URL: https://github.com/apache/doris-website/pull/2548#discussion_r2161298240


##########
docs/sql-manual/sql-functions/scalar-functions/json-functions/to-json.md:
##########
@@ -0,0 +1,158 @@
+---
+{
+    "title": "TO_JSON",
+    "language": "en"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## Description
+
+Converts Doris internal data types to JSONB type. This function allows for 
converting compatible Doris data types into JSON representation without 
precision loss.
+
+## Syntax
+
+```sql
+TO_JSON(value)
+```
+
+## Parameters
+
+| Parameter | Description |
+|-----------|-------------|
+| value     | The value to be converted to JSONB type. Can be one of the types 
compatible with JSON mapping. |
+
+## Return Value
+
+Returns a value of JSONB type.
+
+## Examples
+
+### Basic scalar values
+
+```sql
+SELECT to_json(1), to_json(3.14), to_json("12345");
+```
+
+```text
++------------+---------------+------------------+
+| to_json(1) | to_json(3.14) | to_json("12345") |
++------------+---------------+------------------+
+| 1          | 3.14          | "12345"          |
++------------+---------------+------------------+
+```
+
+### Array conversion
+
+```sql
+SELECT to_json(array(array(1,2,3),array(4,5,6)));
+```
+
+```text
++-------------------------------------------+
+| to_json(array(array(1,2,3),array(4,5,6))) |
++-------------------------------------------+
+| [[1,2,3],[4,5,6]]                         |
++-------------------------------------------+
+```
+
+```sql
+SELECT to_json(array(12,34,null));
+```
+
+```text
++----------------------------+
+| to_json(array(12,34,null)) |
++----------------------------+
+| [12,34,null]               |
++----------------------------+
+```
+
+### Accessing array elements in resulting JSON
+
+```sql
+SELECT json_extract(to_json(array(array(1,2,3),array(4,5,6))), '$.[1].[2]');
+```
+
+```text
++----------------------------------------------------------------------+
+| json_extract(to_json(array(array(1,2,3),array(4,5,6))), '$.[1].[2]') |
++----------------------------------------------------------------------+
+| 6                                                                    |
++----------------------------------------------------------------------+
+```
+
+### Struct conversion
+
+```sql
+SELECT to_json(struct(123,array(4,5,6),"789"));
+```
+
+```text
++------------------------------------------+
+| to_json(struct(123,array(4,5,6),"789"))  |
++------------------------------------------+
+| {"col1":123,"col2":[4,5,6],"col3":"789"} |
++------------------------------------------+
+```
+
+### Accessing object properties in resulting JSON
+
+```sql
+SELECT json_extract(to_json(struct(123,array(4,5,6),"789")),"$.col2");
+```
+
+```text
++----------------------------------------------------------------+
+| json_extract(to_json(struct(123,array(4,5,6),"789")),"$.col2") |
++----------------------------------------------------------------+
+| [4,5,6]                                                        |
++----------------------------------------------------------------+
+```
+
+### Unsupported Doris Types
+
+```sql
+SELECT to_json(makedate(2025,5));
+```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage = Can not find the 
compatibility function signature: to_json(DATE)
+```
+
+## Notes
+
+1. `TO_JSON` supports conversion of Doris data types that have mapping to 
JSONB types:
+   - Numeric types (TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, 
DECIMAL)
+   - Boolean

Review Comment:
   这部分移动到 parameter 介绍那个章节



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to