JSON_VALID

Updated at:

Checks if a string is in a valid JSON format.

Command format

boolean json_valid(<string>)

Parameter description

string: Required. The JSON string to process.

Return value

Returns a value of true or false.

Examples

  • Example 1: Check if "abc" is a valid JSON string.

    select json_valid('"abc"');

    The result is:

    +------+
    | _c0  |
    +------+
    | true |
    +------+
  • Example 2: Check if abc is a valid JSON string.

    select json_valid('abc');

    The result is:

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

Related functions

JSON_VALID is a complex type function. For more information about functions that process complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.