json_valid

description

json_valid functions returns 0 or 1 to indicate whether a value is valid JSON and Returns NULL if the argument is NULL.

Syntax

JSONB json_valid(VARCHAR json_str)

example

  1. parse valid JSON string
  1. MySQL > SELECT json_valid('{"k1":"v31","k2":300}');
  2. +-------------------------------------+
  3. | json_valid('{"k1":"v31","k2":300}') |
  4. +-------------------------------------+
  5. | 1 |
  6. +-------------------------------------+
  7. 1 row in set (0.02 sec)
  1. parse invalid JSON string
  1. MySQL > SELECT json_valid('invalid json');
  2. +----------------------------+
  3. | json_valid('invalid json') |
  4. +----------------------------+
  5. | 0 |
  6. +----------------------------+
  7. 1 row in set (0.02 sec)
  1. parse NULL
  1. MySQL > select json_valid(NULL);
  2. +------------------+
  3. | json_valid(NULL) |
  4. +------------------+
  5. | NULL |
  6. +------------------+
  7. 1 row in set (0.02 sec)

keywords

JSON, VALID, JSON_VALID