I am trying to import a json file to an existing MongoDB collection. Here is the format to my json file:
{
"hostname1": {
"Port 80": {
"Protocol": "tcp",
"State": "",
"Service": "open"
},
"Port 443": {
"Protocol": "tcp",
"State": "open",
"Service": ""
}
},
"hostname2": {
"Port 80": {
"Protocol": "tcp",
"State": "",
"Service": "open"
},
"hostname3": {
"Protocol": "tcp",
"State": "open",
"Service": ""
}
},
"hostname4": {
"Port 80": {
"Protocol": "tcp",
"State": "",
"Service": "open"
},
"Port 443": {
"Protocol": "tcp",
"State": "open",
"Service": ""
}
},
"hostname5": {
"Port 80": {
"Protocol": "tcp",
"State": "",
"Service": "open"
},
"Port 443": {
"Protocol": "tcp",
"State": "open",
"Service": ""
}
}
}
I want the structure of this collection to have the hostname as the index to each output scan. But for some reason the import does not include each hostname, and places a _ID where I would like to have the hostname. Here is what the structure of the collection looks like after the import:
_id
64345263495f463da1b28bbb
Port 80
Object
Protocol
"tcp"
State
""
Service
"open"
Port 443
Object
Protocol
"tcp"
State
"open"
Service
""
_id
64345263495f463da1b28bbc
Port 80
Object
Protocol
"tcp"
State
""
Service
"open"
Port 443
Object
Protocol
"tcp"
State
"open"
Service
""
_id
64345263495f463da1b28bbd
Port 80
Object
Protocol
"tcp"
State
""
Service
"open"
Port 443
Object
Protocol
"tcp"
State
"open"
Service
""
_id
64345263495f463da1b28bbe
Port 80
Object
Protocol
"tcp"
State
""
Service
"open"
Port 443
Object
Protocol
"tcp"
State
"open"
Service
""