Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- 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