Last active
April 16, 2024 23:03
-
-
Save bertwagner/b65698afa5ca0ecb214fae9b2838c615 to your computer and use it in GitHub Desktop.
SQL Server 2016 JSON's Lax versus Strict modes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Lax (default: function will return an error if invalid JSON path specified | |
SELECT JSON_VALUE('{ "Color" : "Red" }', '$.Shape') --lax is the default, so you don't need to be explicitly state it | |
-- Output: NULL | |
SELECT JSON_VALUE('{ "Color" : "Red" }', 'lax $.Shape') | |
-- Output: NULL | |
-- Strict: function will return an error if invalid JSON path specified | |
SELECT JSON_VALUE('{ "Color" : "Red" }', 'strict $.Shape') | |
-- Output: Property cannot be found on the specified JSON path. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment