我有一个类似于以下内容的JSON文件:
{
"101010": {
"ChassisHostname": "host1",
"Slot1": {
"BootROMVersion": "v1",
"ControllerType": "controller",
"ControllerVersion": "v6",
"FirmwareVersion": "v6",
"InstalledKeys": "Plus",
"Port0": {
"BannerDelayTime": "2 seconds",
"BootImage": "Image1",
"BootSkipDelayTime": "5 seconds",
"BootType": "UEFI",
"ChangeMac": "Default",
"EventMergeTimeout": "1500 nanoseconds",
"FirmwareVariant": "Auto",
"InsecureFilters": "Default",
"Link-UpDelayTime": "5 seconds",
"LinkSpeed": "Negotiated automatically",
"MacAddress": "00-00-00-00-00-00",
"MacSpoofing": "Default",
"PfMsi-XInterruptLimit": "12",
"PhysicalFunctionsOnThisPort": "1",
"PortMode": "Default",
"SwitchMode": "Default",
"VfMsi-XInterruptLimit": "2",
"VirtualFunctionsOnEachPf": "0",
"VlanTags": "None"
},
"Port1": {
"BannerDelayTime": "2 seconds",
"BootImage": "Image1",
"BootSkipDelayTime": "5 seconds",
"BootType": "UEFI",
"ChangeMac": "Default",
"EventMergeTimeout": "1500 nanoseconds",
"FirmwareVariant": "Auto",
"InsecureFilters": "Default",
"Link-UpDelayTime": "5 seconds",
"LinkSpeed": "Negotiated automatically",
"MacAddress": "00-00-00-00-00-00",
"MacSpoofing": "Default",
"PfMsi-XInterruptLimit": "12",
"PhysicalFunctionsOnThisPort": "1",
"PortMode": "Default",
"SwitchMode": "Default",
"VfMsi-XInterruptLimit": "2",
"VirtualFunctionsOnEachPf": "0",
"VlanTags": "None"
},
"ProductName": "Product",
"SerialNumber": "10101010"
},
"Slot4": {
"BootROMVersion": "v1",
"ControllerType": "controller",
"ControllerVersion": "v6",
"FirmwareVersion": "v6",
"InstalledKeys": "Plus",
"Port0": {
"BannerDelayTime": "2 seconds",
"BootImage": "Image1",
"BootSkipDelayTime": "5 seconds",
"BootType": "UEFI",
"ChangeMac": "Default",
"EventMergeTimeout": "1500 nanoseconds",
"FirmwareVariant": "Auto",
"InsecureFilters": "Default",
"Link-UpDelayTime": "5 seconds",
"LinkSpeed": "Negotiated automatically",
"MacAddress": "00-00-00-00-00-00",
"MacSpoofing": "Default",
"PfMsi-XInterruptLimit": "12",
"PhysicalFunctionsOnThisPort": "1",
"PortMode": "Default",
"SwitchMode": "Default",
"VfMsi-XInterruptLimit": "2",
"VirtualFunctionsOnEachPf": "0",
"VlanTags": "None"
},
"Port1": {
"BannerDelayTime": "2 seconds",
"BootImage": "Image1",
"BootSkipDelayTime": "5 seconds",
"BootType": "UEFI",
"ChangeMac": "Default",
"EventMergeTimeout": "1500 nanoseconds",
"FirmwareVariant": "Auto",
"InsecureFilters": "Default",
"Link-UpDelayTime": "5 seconds",
"LinkSpeed": "Negotiated automatically",
"MacAddress": "00-00-00-00-00-00",
"MacSpoofing": "Default",
"PfMsi-XInterruptLimit": "12",
"PhysicalFunctionsOnThisPort": "1",
"PortMode": "Default",
"SwitchMode": "Default",
"VfMsi-XInterruptLimit": "2",
"VirtualFunctionsOnEachPf": "0",
"VlanTags": "None"
},
"ProductName": "Product",
"SerialNumber": "10101010"
}
}
目前,我将这些数据用于使用SSIS,将整个JSON文本放在一个列中并使用OPENJSON读取它。该代码如下所示:
DECLARE @json NVARCHAR(MAX)
SET @json= (SELECT TOP 1 [JSON] FROM [STG_Table])
SELECT *
FROM OPENJSON(@json);
由于我的JSON文件在架构中是一致的,我需要一种方法来根据序列号将这些文件解析为键值对。我将使用SSIS导入时使用触发器执行此操作。就目前而言,我知道OPENJSON实际上只将值输入到列中,因此我假设我之后需要对数据进行取消。任何人都可以指出我正确的方向吗?