Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-4548

Compass JSON import object with number as keys results in array of strings

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Gone away
    • 1.24.1
    • No version
    • Import/Export
    • None
    • 3
    • 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

      ```

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              turivishal@gmail.com Vishal Turi
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: