[COMPASS-4548] Compass JSON import object with number as keys results in array of strings Created: 28/Dec/20  Updated: 27/Oct/23  Resolved: 08/Dec/22

Status: Closed
Project: Compass
Component/s: Import/Export
Affects Version/s: 1.24.1
Fix Version/s: No version

Type: Bug Priority: Minor - P4
Reporter: Vishal Turi Assignee: Unassigned
Resolution: Gone away Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to COMPASS-5076 Importing a document with mixed numer... Closed
is related to COMPASS-4418 Compass has no good way to import arr... Closed
Story Points: 3
Documentation Changes: Not Needed

 Description   

Problem Description

.json file having below document,

```

{

  "data": {

    "plans":

{       "1": "14",       "2": "20",       "3": "40"     }

  }

}

```

When we import this file in specific collection by selecting JSON import, It converts object in to array of strings, like below:

```

{ "plans": [null, "14", "20", "40"] }

```

Steps to Reproduce

Open Compass > Connect DB > Select Collection / Create Collection > Click on Add Data button > Select Import File > Popup will open > Select File > Select input file type as JSON > Click on Import button

Expected Results

```

{

  "data": {

    "plans":

{       "1": "14",       "2": "20",       "3": "40"     }

  }

}

```

Actual Results

```

{ "plans": [null, "14", "20", "40"] }

```

Additional Notes

When i import this with `mongoimport` command in mongo shell it is working perfectly,

```

> mongoimport --db dbName --collection collectionName <fileName.json

```



 Comments   
Comment by Le Roux Bodenstein [ 08/Dec/22 ]

We fixed this some time ago as part of another (duplicate?) ticket.

Comment by Vishal Turi [ 28/Dec/20 ]

Recent conversation in Developer Community Forum https://developer.mongodb.com/community/forums/t/mongodb-import-object-with-numbers-as-keys-results-in-array/

Generated at Wed Feb 07 22:36:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.