Microsoft SQL Server Wrapping results with ROOT object


Example

Wraps returned JSON array in additional root object with specified key:

SELECT top 3 object_id, name, type FROM sys.objects
FOR JSON PATH, ROOT('data')

Result of the query would be array of JSON objects inside the wrapper object:

{
  "data":[
           {"object_id":3,"name":"sysrscols","type":"S "},
           {"object_id":5,"name":"sysrowsets","type":"S "},
           {"object_id":6,"name":"sysclones","type":"S "}
         ]
}