Categories:

Conversion Functions , Semi-structured Data Functions (Array/Object)

TO_OBJECT

Converts the input value to an object:

  • For a variant value containing an object, returns this object (in a value of type OBJECT).

  • For a variant value containing JSON null or for NULL input, returns NULL.

  • For all other input values, reports an error.

Syntax

TO_OBJECT( <expr> )

Returns

The data type of the returned value is OBJECT.

Examples

This demonstrates simple usage of the TO_OBJECT function:

SELECT TO_OBJECT(PARSE_JSON('{"a":1}'));
+----------------------------------+
| TO_OBJECT(PARSE_JSON('{"A":1}')) |
|----------------------------------|
| {                                |
|   "a": 1                         |
| }                                |
+----------------------------------+