[COMPASS-4739] Importing a single JSON document should work Created: 29/Mar/21  Updated: 29/Oct/23  Resolved: 03/Mar/23

Status: Closed
Project: Compass
Component/s: Import/Export
Affects Version/s: None
Fix Version/s: 1.36.0

Type: Bug Priority: Major - P3
Reporter: Sergey Petushkov Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on COMPASS-6424 importJSON() import function and tests Closed
depends on COMPASS-6519 Switch to using importCSV() Closed
depends on COMPASS-6520 Switch to using importJSON() Closed
Duplicate
is duplicated by COMPASS-4867 Importing JSON with Arrays does not work Closed
Epic Link: COMPASS-5576
Documentation Changes: Not Needed

 Description   

Problem Description

When a json file contains single document instead of array of documents, import process actually imports values of the keys instead of the value itself. For example, if you have a file with following content:

{
  someKey: { val: 1 },
  anotherKey: { val: 2 }
}

import process will import two documents val: 1 and val: 2.

This is not expected and can not only lead to weird data being added to the database, but also to very confusing error messages if values are not supported document types

Steps to Reproduce

Described above

Expected Results

A single document is imported

Actual Results

Described above

Additional Notes

Having multiple line separated files (as in LDJSON) should also work when importing



 Comments   
Comment by Le Roux Bodenstein [ 03/Mar/23 ]

Fixed by the new import backend. All of these are now valid:

arrays of objects:
[{},{}]

one object per line:
{}
{}

objects split over multiple lines:
{
}
{
}

As a side-effect of the second and third styles a single json object will just work. ie. anything you could type into the insert document modal you could put into a file and import.

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