Skip to content

Instantly share code, notes, and snippets.

@bertwagner
Last active April 16, 2024 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bertwagner/b65698afa5ca0ecb214fae9b2838c615 to your computer and use it in GitHub Desktop.
Save bertwagner/b65698afa5ca0ecb214fae9b2838c615 to your computer and use it in GitHub Desktop.
SQL Server 2016 JSON's Lax versus Strict modes
-- 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