如何在此 json 文件中获取question_id字段?我试过了,但它返回null。
DECLARE @json NVARCHAR(MAX)
SET @json =
N'{
"solution": "xxxxxxxxxxxxxxxxxxxxx",
"options": [
{
"choice_id": 205073,
"choice": "aaaa"
},
{
"choice_id": 205074,
"choice": "bbbb"
},
{
"choice_id": 205075,
"choice": "cccc"
},
{
"choice_id": 205076,
"choice": "dddd"
}
],
"question_id": 12345
}'
SELECT * FROM
OPENJSON ( @json, '$.options')
WITH (
choice_id varchar(8000) '$.choice_id',
question_id int '$.question_id'
)
Run Code Online (Sandbox Code Playgroud)
结果