how to use for json path, root('User') without array wrapper in sql server 2016

xghobddn  于 2023-05-28  发布在  SQL Server
关注(0)|答案(2)|浏览(139)

Here is what i have tried so far and is throwing error.

(select 1 "code"  FOR JSON path) as [User] ,Without_Array_Wrapper

I want an output like this. {"User":{"code":1}}

5ssjco0h

5ssjco0h1#

Here you go

select 1 [user.code]  FOR JSON path ,Without_Array_Wrapper
gojuced7

gojuced72#

You can try this

SELECT   
   (SELECT 1 Code  FOR JSON PATH, WITHOUT_ARRAY_WRAPPER) as [User]  
FOR JSON PATH,    WITHOUT_ARRAY_WRAPPER

相关问题