TO_JSON

Converts a SQL value to a JSON value.

Analyze Syntax

func.to_json(get_column(table, 'struct_col'))

Analyze Examples

func.to_json(func.named_struct('name', 'Alice', 'age', 30))

┌───────────────────────────┐
 {"name":"Alice","age":30} 
└───────────────────────────┘

SQL Syntax

TO_JSON(<struct_col>)

SQL Examples

SELECT TO_JSON(NAMED_STRUCT('name', 'Alice', 'age', 30));

┌───────────────────────────┐
 {"name":"Alice","age":30} 
└───────────────────────────┘