I do not think that this JSON format is supported in FOR JSON
clause, see this article, although the string ["John","Mary","Dick"]
is considered valid json using ISJSON function.
Your only way probably would be to modify the output yourself like this:
SET NOCOUNT ON
DECLARE @MyCategory TABLE (ID int , Category char(1), [Name] varchar(50))
INSERT INTO @MyCategory VALUES (1, 'A', 'John')
INSERT INTO @MyCategory VALUES (2, 'A', 'Mary')
INSERT INTO @MyCategory VALUES (3, 'A', 'Dick')
INSERT INTO @MyCategory VALUES (4, 'B', 'Sam')
DECLARE @MyJSON varchar(max)
SELECT @MyJSON =
REPLACE(
REPLACE(
(
SELECT [Name] AS ReplaceMe
FROM @MyCategory
WHERE [Category] = 'A'
FOR JSON AUTO
), '{"ReplaceMe":',''
) , '}','')
PRINT @MyJSON
PRINT ISJSON(@MyJSON)
Outputs to:
["John","Mary","Dick"]
1