Accept plans from a file OR from JSON object (couchDB) (#3729)

Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
This commit is contained in:
Shefali Joshi 2021-03-03 14:50:48 -08:00 committed by GitHub
parent 03abb5e5de
commit e70a636073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,14 @@
export function getValidatedPlan(domainObject) {
let jsonString = domainObject.selectFile.body;
let body = domainObject.selectFile.body;
let json = {};
try {
json = JSON.parse(jsonString);
} catch (e) {
return json;
if (typeof body === 'string') {
try {
json = JSON.parse(body);
} catch (e) {
return json;
}
} else {
json = body;
}
return json;