Details
-
Bug
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
3
-
Not Needed
-
Iteration Dolphin
Description
Problem Statement/Rationale
Importing from JSON file a document that looks something like this:
{
|
"foo": { "1": 1, "a": "a" }
|
}
|
will result in the property foo being converted to the array during the import
Steps to Reproduce
Create a json file with documents that have mixed number-like and string keys
Expected Results
Document is uploaded, all values are present in the imported documents, objects are still objects
Actual Results
If a document has mixed keys, it will be converted to an array and all string keys will be lost
Additional Notes
Here's the root cause: https://github.com/mongodb-js/compass/blob/0c6483f7aaea2d9e00a6d09520428111fc808b09/packages/compass-import-export/src/utils/import-apply-types-and-projection.js#L66
If this set encounters a path that ends in a number-like key, it will create an array, if not, it will create an object. If an object has mixed keys, first one will always be a number-like one in this part of the code
Attachments
Issue Links
- is related to
-
COMPASS-4548 Compass JSON import object with number as keys results in array of strings
-
- Closed
-