Ho il mio json_file.json come questo:Importazione JSON da file in MongoDB usando mongoimport
[
{
"project": "project_1",
"coord1": 2,
"coord2": 10,
"status": "yes",
"priority": 7
},
{
"project": "project_2",
"coord1": 2,
"coord2": 10,
"status": "yes",
"priority": 7
},
{
"project": "project_3",
"coord1": 2,
"coord2": 10,
"status": "yes",
"priority": 7
}
]
Quando eseguo il seguente comando per importare questo in mongodb:
mongoimport --db my_db --collection my_collection --file json_file.json
ottengo il seguente errore:
Failed: error unmarshaling bytes on document #0: JSON decoder out of sync - data changing underfoot?
Se aggiungo la bandiera --jsonArray al comando mi importare in questo modo:
imported 3 documents
anziché un documento con il formato json come mostrato nel file originale.
Come posso importare json in mongodb con il formato originale nel file mostrato sopra?
Il formato json originale è mappato su tre documenti. – chridam