Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

CAN_JSON_PARSE function - Amazon Redshift

CAN_JSON_PARSE function

The CAN_JSON_PARSE function parses data in JSON format and returns true if the result can be converted to a SUPER value using the JSON_PARSE function.

Syntax

CAN_JSON_PARSE( {json_string | binary_value} )

Arguments

json_string

An expression that returns serialized JSON in VARCHAR form.

binary_value

A VARBYTE type binary value.

Return type

BOOLEAN

Usage notes

  • CAN_JSON_PARSE returns false for empty strings. It returns NULL when the input argument is null.

Examples

The following example shows CAN_JSON_PARSE running on a properly formed JSON array using a CASE condition. It returns true, so Amazon Redshift runs the JSON_PARSE function on the example value.

SELECT CASE WHEN CAN_JSON_PARSE('[10001,10002,"abc"]') THEN JSON_PARSE('[10001,10002,"abc"]') END; case --------------------- '[10001,10002,"abc"]'

The following example shows CAN_JSON_PARSE running on a value that isn’t JSON format using a CASE condition. It returns false, so Amazon Redshift returns the segment in the ELSE clause of the CASE condition instead.

SELECT CASE WHEN CAN_JSON_PARSE('This is a string.') THEN JSON_PARSE('This is a string.') ELSE 'This is not JSON.' END; case --------------------- "This is not JSON."
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.