Skip to main content

AS_OBJECT

Strict casting VARIANT values to OBJECT data type. If the input data type is not VARIANT, the output is NULL. If the type of value in the VARIANT does not match the output value, the output is NULL.

Syntax

AS_OBJECT( <variant> )

Arguments

ArgumentsDescription
<variant>The VARIANT value

Return Type

Variant contains Object

Examples

SELECT as_object(parse_json('{"k":"v","a":"b"}'));
+--------------------------------------------+
| as_object(parse_json('{"k":"v","a":"b"}')) |
+--------------------------------------------+
| {"k":"v","a":"b"} |
+--------------------------------------------+

SELECT as_object(parse_json('{"name":"John","age":30}'));
+-----------------------------------------------+
| as_object(parse_json('{"name":"John","age":30}')) |
+-----------------------------------------------+
| {"name":"John","age":30} |
+-----------------------------------------------+

-- Returns NULL for non-object values
SELECT as_object(parse_json('[1,2,3]'));
+----------------------------------+
| as_object(parse_json('[1,2,3]')) |
+----------------------------------+
| NULL |
+----------------------------------+
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today