All Products
Search
Document Center

MaxCompute:JSON_VALID

Last Updated:Mar 26, 2026

Checks whether a string is a valid JSON string.

Syntax

boolean json_valid(<string>)

Parameters

Parameter Required Type Description
string Yes STRING The string to validate.

Return value

Returns a BOOLEAN value:

Input Return value
Valid JSON true
Invalid JSON false

Examples

Example 1: Check whether "abc" (a quoted string) is valid JSON.

select json_valid('"abc"');

Result:

+------+
| _c0  |
+------+
| true |
+------+

Example 2: Check whether abc (an unquoted string) is valid JSON.

select json_valid('abc');

Result:

+------+
| _c0  |
+------+
| false |
+------+

Related functions

json_valid is a complex type function. For functions that process ARRAY, MAP, STRUCT, and JSON data, see Complex type functions.