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");
+3 -3
View File
@@ -49,7 +49,7 @@
"json-schema-faker": "^0.5.0-rc11",
"json-schema-to-typescript": "^4.6.5",
"lodash": "^4.17.4",
"next": "4.2.1",
"next": "4.2.3",
"nprogress": "^0.2.0",
"promise-worker": "^1.1.1",
"prop-types": "^15.6.0",
@@ -58,14 +58,14 @@
"react-codemirror2": "^3.0.7",
"react-dom": "16.2.0",
"react-fuzzy-picker": "0.6.0",
"react-github-corner": "^2.0.0",
"react-github-corner": "^2.1.0",
"stringify-object": "^3.2.1",
"transform-css-to-js": "^0.1.1",
"transform-graphql-type-annotations": "^0.1.1",
"transform-json-types": "^0.3.0",
"transform-svg-to-native": "^0.1.3",
"unfetch": "^3.0.0",
"xml-js": "^1.6.1"
"xml-js": "^1.6.2"
},
"devDependencies": {
"all-contributors-cli": "^4.10.1",
+9 -9
View File
@@ -4598,9 +4598,9 @@ next-tick@1:
version "1.0.0"
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
next@4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/next/-/next-4.2.1.tgz#37b5637050235b92a487ca484e20088ace7e37fe"
next@4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/next/-/next-4.2.3.tgz#6f85f9bd6df2c420b4f6425f9f158e82515b7bc8"
dependencies:
ansi-html "0.0.7"
babel-core "6.26.0"
@@ -5714,9 +5714,9 @@ react-fuzzy-picker@0.6.0:
fuzzysearch "^1.0.3"
prop-types "^15.6.0"
react-github-corner@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/react-github-corner/-/react-github-corner-2.0.0.tgz#e248f9110afdc03a5e1168f95714795459b1b380"
react-github-corner@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/react-github-corner/-/react-github-corner-2.1.0.tgz#559363f5407e932db47e942f639d165e81827be4"
react-hot-loader@3.1.1:
version "3.1.1"
@@ -7275,9 +7275,9 @@ xdg-basedir@^2.0.0:
dependencies:
os-homedir "^1.0.0"
xml-js@^1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.1.tgz#e94121bf73acf54126241fe7d913508f4cf49e90"
xml-js@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.2.tgz#4c4cb8413998f73701a202a1b8b2f17c985a72c5"
dependencies:
sax "^1.2.4"