Created
September 24, 2017 04:54
-
-
Save samirbehara-zz/f835ccb13a17ae78ba40b47a5cb0b46b to your computer and use it in GitHub Desktop.
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
-- JSON_MODIFY Demonstration to update the value of a property in JSON string | |
DECLARE @json nvarchar(max) | |
SET @json =N' | |
{ | |
"Person": [ | |
{ | |
"Name": { | |
"FirstName": "Catherine", | |
"LastName": "Abel" | |
}, | |
"Address": { | |
"State": "VA", | |
"Zip": "24153" | |
} | |
} | |
] | |
}' | |
PRINT @json | |
IF (ISJSON(@json) = 1) | |
PRINT 'It is a Valid JSON' --Valid JSON | |
ELSE | |
PRINT 'It is an Invalid JSON string' | |
PRINT JSON_MODIFY (@json, '$.Person[0].Address.Zip' , '35043'); | |
PRINT @json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment