Hi,@Andrew Hall
Welcome to Microsoft T-SQL Q&A Forum!
When you add Test2 with a second object,don't forget to add [ ]
Please check this:
DECLARE @OriginalJSON NVARCHAR(4000), @newjson NVARCHAR(4000);
SET @OriginalJSON = '{"Test":{"item1": {"Value" : "test1"}}, "Test2": [{"item11": {"Value" : "test11"}, "item12": {"Value" : "test12"}}]}';
SELECT @OriginalJSON AS 'Before Update',
JSON_MODIFY(@OriginalJSON, '$.Test.item1', NULL) AS 'Updated JSON';
print @OriginalJSON
Output:
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.