I have a large JSON structure (array of arrays) consisting of string values (e.g. "1") that identify each section.
How would I utilize OPENJSON to parse all the information correctly?
A subset of the JSON data:
{"products":[
{"1":[
{"product":"01-223","category":"32","item":"16326","location":"06","quantity":"71"},
{"product":"01-223","category":"32","item":"16327","location":"06","quantity":"44"},
{"product":"01-223","category":"32","item":"16328","location":"06","quantity":"47"}
]
}
]}
I've tried numerous variations of the following without any success:
SELECT @json1 = BulkColumn
FROM OPENROWSET (BULK 'C:\4\test3.json', SINGLE_CLOB) as j
SELECT product, category, item FROM OPENJSON (@json1, '$.products[0]')
With (
product varchar(20),
category varchar(20),
item varchar(20)
)
Does anyone know what I'm doing wrong?
$.products[0]."1"instead of$.products[0], but this assumes you only want section 1.