From 8ac466165ab59542f800a0e71d2d962a457c933f Mon Sep 17 00:00:00 2001 From: Sebastien Jourdain Date: Wed, 9 Mar 2016 13:42:58 -0700 Subject: [PATCH] fix(Simput): Fix serialization/deserialization issue with simput model --- src/workflows/pyfr/components/steps/Input/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/workflows/pyfr/components/steps/Input/index.js b/src/workflows/pyfr/components/steps/Input/index.js index aefb286b..c693252c 100644 --- a/src/workflows/pyfr/components/steps/Input/index.js +++ b/src/workflows/pyfr/components/steps/Input/index.js @@ -93,11 +93,15 @@ export default React.createClass({ metadata: { model: JSON.stringify(jsonData) }, }).then((resp) => { var newSim = deepClone(this.props.simulation); - newSim.steps[this.props.step].metadata.model = jsonData; + newSim.steps[this.props.step].metadata.model = JSON.stringify(jsonData); client.invalidateSimulation(newSim); }); } else { - jsonData = JSON.parse(jsonData); + if (typeof jsonData === 'string') { + jsonData = JSON.parse(jsonData); + } else { + console.log('Can not convert jsonData (?)', jsonData); + } } // Push model to state @@ -116,7 +120,7 @@ export default React.createClass({ metadata: { model: JSON.stringify(jsonData) }, }).then((resp) => { var newSim = deepClone(this.props.simulation); - newSim.steps[this.props.step].metadata.model = jsonData; + newSim.steps[this.props.step].metadata.model = JSON.stringify(jsonData); client.invalidateSimulation(newSim); });