SQL Server 2016 JSON: Select array of strings instead of array of objects
<p>I am new to JSON in SQL Server and can't figure out how to return a simple array of strings:</p>
<pre class="lang-sql prettyprint-override"><code>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
</code></pre>
<p>This returns an array of objects:</p>
<pre class="lang-json prettyprint-override"><code>[{&quot;value&quot;:&quot;foo&quot;},{&quot;value&quot;:&quot;bar&quot;},{&quot;value&quot;:&quot;test&quot;},{&quot;value&quot;:&quot;ok&quot;}]
</code></pre>
<p>I would like it to return:</p>
<pre><code>[&quot;foo&quot;,&quot;bar&quot;,&quot;test&quot;,&quot;ok&quot;]
</code></pre>
<p>Can this even be done?</p>