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
Parameter | Type | Required | Description |
---|---|---|---|
expr | VARCHAR | Yes | The JSON string to parse |
as_type | VARCHAR | Yes | The 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