mirror of
https://github.com/ritz078/transform.git
synced 2026-11-25 10:14:22 +03:00
add js object to JSON
This commit is contained in:
1 parent
050a2eeb87
commit
ab7c0c6b81
2 files changed
+36
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import React, { PureComponent } from "react";
|
||||
import Layout from "../components/Layout";
|
||||
import stringify from "stringify-object"
|
||||
import ConversionPanel from "../components/ConversionPanel";
|
||||
import text from "../utils/dummy-object-json"
|
||||
|
||||
const defaultText = stringify(eval(`(${text})`))
|
||||
|
||||
export default class Main extends PureComponent {
|
||||
|
||||
getTransformedValue = newValue => {
|
||||
return JSON.stringify(eval('(' + newValue + ')'), null ,2)
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Layout pathname={this.props.url.pathname}>
|
||||
<ConversionPanel
|
||||
leftTitle="JS Object"
|
||||
rightTitle="JSON"
|
||||
url={this.props.url}
|
||||
leftMode="javascript"
|
||||
rightMode="json"
|
||||
getTransformedValue={this.getTransformedValue}
|
||||
name={"js_to_json"}
|
||||
defaultText={defaultText}
|
||||
/>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,11 @@ export const categorizedRoutes = [
|
||||
label: "JSON to MobX-State-Tree Model",
|
||||
path: "/json-to-mobx-state-tree",
|
||||
desc: "An online REPL for converting JSON to generate Mobx State Tree."
|
||||
},
|
||||
{
|
||||
label: "JS Object to JSON",
|
||||
path: "/js-object-to-json",
|
||||
desc: "An online REPL for converting JS Object to JSON."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user