3

T-Sql JSON_MODIFY function has some issue its adding wrapper when appending a new value pair like

  declare @jsonstring varchar(max) ='{"Width":"100%","Length":"45%"}'  
  select JSON_MODIFY(@jsonstring,'append $.Height ','50%' ) 

-- output {"Width":"100%","Length":"45%","Height":["50%"]}
-- Its adding wrapper i am unable to remove that wrapper
-- expecting output {"Width":"100%","Length":"45%","Height":"50%"}

1 Answer 1

5

Try this query:

declare @jsonstring varchar(max) ='{"Width":"100%","Length":"45%"}'  
select JSON_MODIFY(@jsonstring,'$.Height ','50%' ) 

The documentation for append says:

"Optional modifier that specifies that the new value should be appended to the array referenced by < json path >."

Sign up to request clarification or add additional context in comments.

1 Comment

That is it. My idea was to use JSON_MODIFY twice demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.