I am new to JSON in SQL Server and can't figure out how to return a simple array of strings:
DECLARE @T TABLE ([value] NVARCHAR(MAX))
INSERT INTO @T ([value]) VALUES ('foo')
INSERT INTO @T ([value]) VALUES ('bar')
INSERT INTO @T ([value]) VALUES ('test')
INSERT INTO @T ([value]) VALUES ('ok')
SELECT [value]
FROM @T
FOR JSON PATH
This returns an array of objects:
[{"value":"foo"},{"value":"bar"},{"value":"test"},{"value":"ok"}]
I would like it to return:
["foo","bar","test","ok"]
Can this even be done?