{"id":4079,"date":"2015-11-15T23:40:16","date_gmt":"2015-11-15T18:10:16","guid":{"rendered":"http:\/\/sqlhints.com\/?p=4079"},"modified":"2015-12-23T07:19:47","modified_gmt":"2015-12-23T01:49:47","slug":"isjson-function-in-sql-server-2016","status":"publish","type":"post","link":"https:\/\/sqlhints.com\/2015\/11\/15\/isjson-function-in-sql-server-2016\/","title":{"rendered":"ISJSON Function in Sql Server 2016"},"content":{"rendered":"<p style=\"text-align: justify;\"><strong>ISJSON <\/strong>function validates whether the string parameter supplied to it is a valid JSON or not. If supplied string is a valid JSON then it will return value as 1, otherwise it returns the value 0. In case input is a NULL then it returns output as NULL.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"brush: sql; gutter: false\">ISJSON( String_Expression )<\/pre>\n<p style=\"text-align: justify;\"><strong>WHERE<\/strong> <strong>String_Expression <\/strong>can be a table column or a string (i.e. Varchar\/NVarchar) variable or a string constant. And this string expression is evaluated to check whether it is a valid JSON.<\/p>\n<p><strong>[ALSO READ]:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/10\/25\/json-in-sql-server-2016\/\" target=\"_blank\">Native JSON Support in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/for-json-clause-in-sql-server-2016\/\" target=\"_blank\">FOR JSON Clause in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/22\/openjson-function-in-sql-server-2016\/\" target=\"_blank\">OPENJSON Function in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/json_value-function-in-sql-server-2016\/\" target=\"_blank\">JSON_VALUE Function in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/json_query-function-in-sql-server-2016\/\" target=\"_blank\">JSON_QUERY Function in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/lax-and-strict-json-path-modes-in-sql-server-2016\/\" target=\"_blank\">lax and strict JSON Path modes in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/28\/indexing-strategy-for-json-value-in-sql-server-2016\/\" target=\"_blank\">Indexing Strategy for JSON Value in Sql Server 2016<\/a><\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Let us understand this function with extensive list of examples:<\/p>\n<p style=\"text-align: justify;\"><strong>Example 1:<\/strong> Input is a valid JSON, in this case the ISJSON function will return value as 1<\/p>\n<pre class=\"brush: sql; gutter: false\">DECLARE @JSONText NVarchar(Max) = &#039;[{&quot;Id&quot;:1,&quot;Name&quot;:&quot;Basavaraj&quot;},\r\n\t\t\t             {&quot;Id&quot;:2,&quot;Name&quot;:&quot;Kalpana&quot;}]&#039;\r\nIF ISJSON ( @JSONText ) = 1\r\n\tPRINT &#039;Valid JSON&#039;<\/pre>\n<p><strong>RESULT:<\/strong><br \/>\n<a href=\"https:\/\/sqlhints.com\/wp-content\/uploads\/2015\/11\/ISJSON-Valid-JSON.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-4080 alignnone\" src=\"https:\/\/sqlhints.com\/wp-content\/uploads\/2015\/11\/ISJSON-Valid-JSON.jpg\" alt=\"ISJSON Valid JSON\" width=\"500\" height=\"181\" \/><\/a><\/p>\n<p style=\"text-align: justify;\"><strong>Example 2:<\/strong> Input is an InValid JSON, in this case the ISJSON function will return value as 0<\/p>\n<pre class=\"brush: sql; gutter: false\">DECLARE @JSONText NVarchar(Max) = &#039;Basavaraj&#039;\r\nIF ISJSON ( @JSONText ) = 0\r\n\tPRINT &#039;InValid JSON&#039;<\/pre>\n<p><strong>RESULT:<\/strong><br \/>\n<a href=\"https:\/\/sqlhints.com\/wp-content\/uploads\/2015\/11\/ISJSON-InValid-JSON.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-4081 alignnone\" src=\"https:\/\/sqlhints.com\/wp-content\/uploads\/2015\/11\/ISJSON-InValid-JSON.jpg\" alt=\"ISJSON InValid JSON\" width=\"400\" height=\"140\" \/><\/a><\/p>\n<p style=\"text-align: justify;\"><strong>Example 3:<\/strong> Input is a NULL value, in this case the ISJSON function will return value as 0<\/p>\n<pre class=\"brush: sql; gutter: false\">SELECT ISJSON ( NULL ) &#039;ISJSON RESULT&#039;\r\n<\/pre>\n<p><strong>RESULT:<\/strong><br \/>\n<a href=\"https:\/\/sqlhints.com\/wp-content\/uploads\/2015\/11\/ISJSON-NULL-OutPut.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-4082 alignnone\" src=\"https:\/\/sqlhints.com\/wp-content\/uploads\/2015\/11\/ISJSON-NULL-OutPut.jpg\" alt=\"ISJSON NULL OutPut\" width=\"400\" height=\"90\" \/><\/a><br \/>\n<strong>[ALSO READ]:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/10\/25\/json-in-sql-server-2016\/\" target=\"_blank\">Native JSON Support in Sql Server 2016<\/a>\n<ul>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/for-json-clause-in-sql-server-2016\/\" target=\"_blank\">FOR JSON Clause in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/22\/openjson-function-in-sql-server-2016\/\" target=\"_blank\">OPENJSON Function in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/isjson-function-in-sql-server-2016\/\" target=\"_blank\">ISJSON Function in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/json_value-function-in-sql-server-2016\/\" target=\"_blank\">JSON_VALUE Function in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/json_query-function-in-sql-server-2016\/\" target=\"_blank\">JSON_QUERY Function in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/lax-and-strict-json-path-modes-in-sql-server-2016\/\" target=\"_blank\">lax and strict JSON Path modes in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/28\/indexing-strategy-for-json-value-in-sql-server-2016\/\" target=\"_blank\">Indexing Strategy for JSON Value in Sql Server 2016<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/12\/drop-if-exists-statement-in-sql-server-2016\/\" target=\"_blank\">DROP IF EXISTS Statement in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/11\/29\/compare-execution-plan-in-sql-server-2016\/\" target=\"_blank\">Compare Execution Plans in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/12\/11\/live-query-statistics-in-sql-server-2016\/\" target=\"_blank\">Live Query Statistics in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/12\/12\/datediff_big-function-in-sql-server-2016\/\" target=\"_blank\">DATEDIFF_BIG Function in Sql Server 2016<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/12\/12\/difference-between-datediff-and-datediff_big-functions-in-sql-server\/\" target=\"_blank\">Difference between DATEDIFF and DATEDIFF_BIG functions in Sql Server<\/a><\/li>\n<li><a href=\"https:\/\/sqlhints.com\/2015\/12\/15\/session_context-in-sql-server-2016\/\" target=\"_blank\">SESSION_CONTEXT in Sql Server 2016<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>ISJSON function validates whether the string parameter supplied to it is a valid JSON or not. If supplied string is a valid JSON then it will return value as 1, otherwise it returns the value 0. In case input is a NULL then it returns output as NULL. Syntax: ISJSON( String_Expression ) WHERE String_Expression can &hellip; <a href=\"https:\/\/sqlhints.com\/2015\/11\/15\/isjson-function-in-sql-server-2016\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">ISJSON Function in Sql Server 2016<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3,830],"tags":[851,863,910,912,911,850,865,913,909,914,915,871,832,895,864,321,835,862,986,834],"class_list":["post-4079","post","type-post","status-publish","format-standard","hentry","category-sql-server","category-sql-server-2016","tag-isjson","tag-isjson-function","tag-isjson-function-in-sql","tag-isjson-function-in-sql-server","tag-isjson-function-in-sql-server-2016","tag-isjson-function-sql","tag-json","tag-json-functions","tag-json-functions-in-sql","tag-json-functions-in-sql-server","tag-json-functions-in-sql-server-2016","tag-json-in-sql","tag-json-in-sql-server","tag-json-in-sql-server-2016","tag-json-sql","tag-sql","tag-sql-2016","tag-sql-isjson","tag-sql-server","tag-sql-server-2016"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3xNAz-13N","_links":{"self":[{"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/posts\/4079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/comments?post=4079"}],"version-history":[{"count":12,"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/posts\/4079\/revisions"}],"predecessor-version":[{"id":4378,"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/posts\/4079\/revisions\/4378"}],"wp:attachment":[{"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/media?parent=4079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/categories?post=4079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlhints.com\/wp-json\/wp\/v2\/tags?post=4079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}