I'm trying to parse the following JSON document :
DECLARE @doc nvarchar(max) = '
{
"0": {
"start_time": "1685959230501",
"timestamp": "10:00:30",
"running_time": "1.2s",
},
"1": {
"start_time": "1685959230502",
"timestamp": "10:00:30",
"running_time": "1.2s",
},
"2": {
"start_time": "1685959230886",
"timestamp": "10:00:30",
"running_time": "889.3ms",
},
"3": {
"start_time": "1685959230887",
"timestamp": "10:00:30",
"running_time": "883.9ms",
}"'
SELECT *
FROM OPENJSON(@doc, '$.sql:identity()')
WITH (
start_time datetime2(3) N'$.start_time'
, [timestamp] varchar(128) N'$.timestamp'
, running_time varchar(128) N'$.running_time'
) AS i
However it raises the following exception :
Msg 13607, Level 16, State 4, Line 24 JSON path is not properly formatted. Unexpected character ':' is found at position 5.
I tried several ways using the second parameter of the OPENJSON function, but none has been working. Does someone have an idea ?