JSON_PARSE_AS

All functions > JSON > JSON_PARSE_AS

Returns the value of a JSON expression represented as a string in the given type.

Syntax

JSON_PARSE_AS(expr, as_type)
sql

Arguments

ParameterTypeRequiredDescription
exprVARCHARYesThe JSON string to parse
as_typeVARCHARYesThe target data type to cast the parsed value to

Returns

The parsed JSON value cast to the specified type

Notes

  • Parses JSON string and casts to a specific type in one operation
  • Combines JSON_PARSE and CAST functionality
  • Useful for extracting typed values from JSON strings
  • Supports casting to numeric types (BIGINT, DOUBLE, DECIMAL)
  • Supports casting to VARCHAR and other SQL types
  • Returns NULL if parsing fails or cast is not possible
  • More efficient than separate parse and cast operations
  • Type must be a valid SQL data type

Examples

Last update at: 2025/10/13 10:23:46