Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to parse the Json file with its relation_tree and split into multiple Json file for each child without any hard coding of Node/Tag (As structure of Json is not always same also very lengthy json). Input and Output is pasted below : #326

Open
TrendingAnamika opened this issue Feb 22, 2020 · 0 comments

Comments

@TrendingAnamika
Copy link

For Example this is the input Data, where I need relation tree like below output :

{
"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
}
}
]
}
}
}

OUTPUT :

{ "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 }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant