Skip to main content
Converts a string to a JSON value. Tip All of the JSON functions and operators are listed in the navigation and on the overview page Accelerate your queries with generated columns

Syntax

Parameters

string_expr: the expression that represents the string. Only the STRING, VARCHAR, and CHAR data types are supported.

Return value

Returns a JSON value.
Note: If the string cannot be parsed into a standard JSON value, the PARSE_JSON function returns NULL (see Example 5). For information about the JSON specifications, see RFC 7159.

Examples

Example 1: Convert a STRING value of 1 to a JSON value of 1.
Example 2: Convert an array of the STRING data type to a JSON array.
Example 3: Convert an object of the STRING data type to a JSON object.
Example 4: Construct a JSON value of NULL.
Example 5: If the string cannot be parsed into a standard JSON value, the PARSE_JSON function returns NULL. In this example, star is not enclosed in double quotation marks (”). Therefore, the PARSE_JSON function returns NULL.
Example 6: If a JSON key contains a ’.’, for example, ‘a.1’, it must be escaped with ’\’ or you need to enclose the entire key value along with double quotes in single quotes.

Keywords

parse_json, parse json