| title | ISJSON (Transact-SQL) | Microsoft Docs | ||
|---|---|---|---|
| ms.custom | |||
| ms.date | 07/17/2017 | ||
| ms.prod | sql | ||
| ms.prod_service | database-engine, sql-database | ||
| ms.service | |||
| ms.component | t-sql|functions | ||
| ms.reviewer | douglasl | ||
| ms.suite | sql | ||
| ms.technology |
|
||
| ms.tgt_pltfrm | |||
| ms.topic | language-reference | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | c836f3d3-3e17-44ae-92bf-f341918896c3 | ||
| caps.latest.revision | 12 | ||
| author | jovanpop-msft | ||
| ms.author | jovanpop | ||
| manager | craigg | ||
| ms.workload | On Demand |
[!INCLUDEtsql-appliesto-ss2016-asdb-xxxx-xxx-md]
Tests whether a string contains valid JSON.
Transact-SQL Syntax Conventions
ISJSON ( expression ) expression
The string to test.
Returns 1 if the string contains valid JSON; otherwise, returns 0. Returns null if expression is null.
Does not return errors.
ISJSON does not check the uniqueness of keys at the same level.
The following example runs a statement block conditionally if the parameter value @param contains valid JSON.
DECLARE @param <data type>
SET @param = <value>
IF (ISJSON(@param) > 0)
BEGIN
-- Do something with the valid JSON value of @param.
END
The following example returns rows in which the column json_col contains valid JSON.
SELECT id, json_col
FROM tab1
WHERE ISJSON(json_col) > 0