INPUT JSON :
{
“Start”:{
“HInfo”:{
“HInfoID”:“ABCD1234”,
“SUType”:“OnStup”,
“SModel”:“Test”,
“Hostname”:“Dummy”,
“SType”:“Laptop”,
“Monitor”:{
“HInfoID”:“ABCD1234”,
“Index”:0,
“Type”:“Lenovo”,
“VSData”:“XYZVN”
},
“OS”:“MSW-07”,
“LRTime”:“2017-05-04”,
“Cables”:[
{
“HInfoID”:“ABCD1234”,
“Index”:0,
“Name”:“LC”,
“Status”:“Installed”
},
{
“HInfoID”:“ABCD1234”,
“Index”:1,
“Name”:“WLSwitch”,
“Status”:“Off”
},
{
“HInfoID”:“ABCD1234”,
“Index”:2,
“Name”:“WLAN”,
“Status”:“Installed”
}
],
“NFan”:{
“HInfoID”:“ABCD1234”,
“Index”:0
},
“Disk”:[
{
“HInfoID”:“ABCD1234”,
“Index”:0,
“Name”:“DISK0”,
“MKMdl”:“THB”,
“BW_MB”:694,
“Partition”:[
{
“HInfoID”:“6ABCD1234”,
“DGID”:“ABCD1234”,
“Index”:0,
“Name”:“Not Used”,
“SM”:500
},
{
“HInfoID”:“ABCD1234”,
“DGID”:“ABCD1234”,
“Index”:1,
“Name”:“C:”,
“SM”:476438
}
]
},
{
“HInfoID”:“ABCD1234”,
“Index”:1,
“Name”:“DISK1”,
“MKMdl”:“JFlsh”,
“BW_MB”:0,
“Partition”:{
“HInfoID”:“ABCD1234”,
“DGID”:“ABCD1234”,
“Index”:0,
“Name”:“E:”,
“SM”:7727
}
}
]
}
}
}
Expected Output JSON Files :
- { “obj_class”:“HInfo”, “obj_instance”:“HInfo”, “relation_tree”:“Start.HInfo”, “HInfo”:{ “HInfoID”: “ABCD1234”, “SUType”:“OnStup”, “SModel”:“Test”, “Hostname”:“Dummy”, “SType”:“Laptop”, “OS”:“MSW-07”, “LRTime”:“2017-05-04” }}
- { “obj_class”:“Monitor”, “obj_instance”:“Monitor-1”, “relation_tree”:“Start.HInfo.Monitor.Monitor-1”, //This Monitor-1 indicates that Monitor has only 1 instance “Monitor”:{ “HInfoID”:“ABCD1234”, “Index”:“0”, “Type”:“Lenovo”, “VSData”: “XYZVN” }}
- { “obj_class”:“Cables”, “obj_instance”:“Cables-1”, “relation_tree”:“Start.HInfo.Cables.Cables-1”,
“Cables”:{ “HInfoID”: “ABCD1234”, “Index”:“0”, “Name”:“LC”, “Status”:“Installed” }} - { “obj_class”:“Cables”, “obj_instance”:“Cables-2”, “relation_tree”:“Start.HInfo.Cables.Cables-2”,
“Cables”:{ “HInfoID”: “ABCD1234”, “Index”:“1”, “Name”:“WLSwitch”, “Status”:“Off” }} - { “obj_class”:“Cables”, “obj_instance”:“Cables-3”, “relation_tree”:“Start.HInfo.Cables.Cables-3”,
“Cables”:{ “HInfoID”:“ABCD1234”, “Index”:“2”, “Name”:“WLAN”, “Status”:“Installed” }} - { “obj_class”:“NFan”, “obj_instance”:“NFan-1”, “relation_tree”:“Start.HInfo.NFan.NFan-1”,
“NFan”:{ “HInfoID”: “ABCD1234”, “Index”: “0” }} - { “obj_class”:“Disk”, “obj_instance”:“Disk-1”, “relation_tree”:“Start.HInfo.Disk.Disk-1”,
“Disk”:{ “HInfoID”:“ABCD1234”, “Index”:0, “Name”:“DISK0”, “MKMdl”:“THB”, “BW_MB”:694 }} - { “obj_class”:“Partition”, “obj_instance”:“Partition-1”, “relation_tree”:“Start.HInfo.Disk.Disk-1.Partition.Partition-1”, “Partition”:{ “HInfoID”:“ABCD1234”, “DGID”:“ABCD1234”, “Index”:0, “Name”:“Not Used”, “SM”:500 }}
- { “obj_class”:“Partition”, “obj_instance”:“Partition-2”, “relation_tree”:“Start.HInfo.Disk.Disk-1.Partition.Partition-2”,
“Partition”:{ “HInfoID”:“ABCD1234”, “DGID”:“ABCD1234”, “Index”:1, “Name”:“C:”, “SM”:476438 }} - { “obj_class”:“Disk”, “obj_instance”:“Disk-2”, “relation_tree”:“Start.HInfo.Disk.Disk-2”, “Disk”:{ “HInfoID”:“ABCD1234”, “Index”:1, “Name”:“DISK1”, “MKMdl”:“JFlsh”, “BW_MB”:0 }}
- { “obj_class”:“Partition”, “obj_instance”:“Partition-1”, “relation_tree”:“Start.HInfo.Disk.Disk-2.Partition.Partition-1”, “Partition”:{ “HInfoID”:“ABCD1234”, “DGID”:“ABCD1234”, “Index”:0, “Name”:“E:”, “SM”:7727 }}
Is there any generic way to split the nested json file into multiple json along with with its relation tree at very first line (without any hard coding of Node/Tag) using Scala? Instant help or suggestion is appreciated.