我有以下声明,我试图在 Sql Server 2016 CTP 3 中执行:
DECLARE @json nvarchar(max)
set @json = '[
{ "name": "John" },
{ "name": "Jane", "surname": "Doe" }
]'
select
'othervalue' as o,
@json as j
for json path
问题是当我执行这些语句时,我得到以下 Json 字符串(带有转义字符):
[{"o":"othervalue","j":"[ \r\n { \"name\": \"John\" },\r\n { \"name\": \"Jane\", \"surname\": \"Doe\" }\r\n]"}]
我的问题是如何正确选择带有 select 语句的 Json 字符串(没有转义字符)。
谢谢