From e70a636073ec77e59e6132906642bb7985c0a658 Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Wed, 3 Mar 2021 14:50:48 -0800 Subject: [PATCH] Accept plans from a file OR from JSON object (couchDB) (#3729) Co-authored-by: Deep Tailor --- src/plugins/plan/util.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/plan/util.js b/src/plugins/plan/util.js index 7cc522fe5a..efa5409058 100644 --- a/src/plugins/plan/util.js +++ b/src/plugins/plan/util.js @@ -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;