Collections:
JSON_VALID() - Validating JSON Value
How to verify if value is a JSON (JavaScript Object Notation) value using the JSON_VALID() function?
✍: FYIcenter.com
JSON_VALID(val) is a MySQL built-in function that
returns 1 if the given value is a valid JSON value.
For example:
SELECT JSON_VALID('hello'), JSON_VALID('"hello"');
-- +---------------------+-----------------------+
-- | JSON_VALID('hello') | JSON_VALID('"hello"') |
-- +---------------------+-----------------------+
-- | 0 | 1 |
-- +---------------------+-----------------------+
SELECT JSON_VALID('123'), JSON_VALID('"123"');
-- +-------------------+---------------------+
-- | JSON_VALID('123') | JSON_VALID('"123"') |
-- +-------------------+---------------------+
-- | 1 | 1 |
-- +-------------------+---------------------+
SELECT JSON_VALID('{"a": 1}'), JSON_VALID('(1,2,3)');
-- +------------------------+-----------------------+
-- | JSON_VALID('{"a": 1}') | JSON_VALID('(1,2,3)') |
-- +------------------------+-----------------------+
-- | 1 | 0 |
-- +------------------------+-----------------------+
Reference information of the JSON_VALID() function:
JSON_VALID(val): int Returns 0 or 1 to indicate whether a value is valid JSON value. Arguments, return value and availability: val: Required. The value to be verified int: Return value. The verification result. Available since MySQL 5.7.
⇒ JSON_VALUE() - Converting JSON Value
⇐ JSON_UNQUOTE() - Unquoting JSON String
2023-12-17, 1172🔥, 0💬
Popular Posts:
How To Use GO Command in "sqlcmd" in SQL Server? "sqlcmd" is a command line client application to ru...
How to set database to be READ_ONLY in SQL Server? Databases in SQL Server have two update options: ...
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
How To Get a List of All Tables with "sys.tables" View in SQL Server? If you want to see the table y...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...