For JSON Path Formatting For JSON Path Formatting json json

For JSON Path Formatting


I only updated your replace statements to get rid of the quotation marks in "[number]", as below:-

select c.call_id as [call.id],    json_query(replace(replace((        select x.[key] as question_id        from [call].[triage_questions] tq            cross apply openjson(questions, '$') as x        where value = 1 and tq.call_id = c.call_id        order by x.[key]        for json path    ), N'{"question_id":"', N''), '"}', '')) as [call.yes_answers]from [call].[dimension] cwhere call_id = 200643for json path

In my testing, the output is as below:-

[{"call":{"id":200643,"yes_answers":[220,221,222,223,224,225,226,227,228,229,230,231,232]}}]