allow JS object instead of JSON

This commit is contained in:
ritz078 committed 2018-01-19 21:35:08 +05:30
1 parent c8ae576c14
commit c93caa6765
3 files changed
+19 -14

No files matched your search

+7 -2
View File
@@ -185,7 +185,7 @@ export default class ConversionPanel extends PureComponent {
};
onChange = async (newValue, leftSplitValue) => {
const { prettifyRightPanel, rightMode } = this.props;
const { prettifyRightPanel, rightMode, leftMode } = this.props;
const nValue = newValue || this.state.value;
const splitValue =
@@ -194,7 +194,12 @@ export default class ConversionPanel extends PureComponent {
: this.state.splitValue;
try {
let code = await this.props.getTransformedValue(nValue, splitValue);
// Convert JS to JSON
const json =
leftMode === "json"
? JSON.stringify(eval("(" + nValue + ")", null, 2))
: nValue;
let code = await this.props.getTransformedValue(json, splitValue);
code = code.prettyCode || code;
if (prettifyRightPanel) {
this.passCodeToWorker(code, rightMode, "resultValue");