Merge pull request #2719 from appleYaks/import-backward-compatible

Make DB Import backwards compatible
This commit is contained in:
Hannah Wolfe 2014-05-11 16:17:17 +01:00
commit 25ec0f3f75

View File

@ -63,6 +63,11 @@ db = {
// Parse the json data
try {
importData = JSON.parse(fileContents);
// if importData follows JSON-API format `{ db: [exportedData] }`
if (_.keys(importData).length === 1 && Array.isArray(importData.db)) {
importData = importData.db[0];
}
} catch (e) {
errors.logError(e, "API DB import content", "check that the import file is valid JSON.");
return when.reject(new errors.BadRequest("Failed to parse the import JSON file"));