WITHOUT_ARRAY_WRAPPER option in FOR JSON clause will remove array brackets from the JSON output. This is useful if you are returning single row in the query.
Note: this option will produce invalid JSON output if more than one row is returned.
Input table data (People table)
Id | Name | Age |
---|---|---|
1 | John | 23 |
2 | Jane | 31 |
Query
SELECT Id, Name, Age
FROM People
WHERE Id = 1
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
Result
{"Id":1,"Name":"John","Age":23}