add json to toml and toml to json (#299)

* add JSON to TOML

* change function name to JsonToToml

* add TOML to JSON

* add package iarna-toml
This commit is contained in:
Nasrul Faizin authored and GitHub committed 2021-08-30 00:42:09 +05:30
1 parent efac463f2d
commit baa447348c
6 files changed
+71 -1

No files matched your search

+9
View File
@@ -433,3 +433,12 @@ export interface Props {
/** Should the name be rendered in bold */
priority?: boolean
}`;
export const toml = `userId = 1
id = 1
title = "delectus aut autem"
completed = false
[company]
id = 12
name = "Transform Inc"`;
+1
View File
@@ -36,6 +36,7 @@
"@graphql-codegen/typescript-resolvers": "^1.19.4",
"@graphql-codegen/typescript-stencil-apollo": "^1.18.7",
"@graphql-codegen/typescript-urql": "^2.0.9",
"@iarna/toml": "^2.2.5",
"@khanacademy/flow-to-ts": "^0.5.2",
"@monaco-editor/react": "^4.2.1",
"@openapi-contrib/json-schema-to-openapi-schema": "^2.0.0",
+21
View File
@@ -0,0 +1,21 @@
import ConversionPanel from "@components/ConversionPanel";
import { useCallback } from "react";
import * as React from "react";
import { stringify } from "@iarna/toml";
export default function JsonToToml() {
const transformer = useCallback(
({ value }) => Promise.resolve(stringify(JSON.parse(value))),
[]
);
return (
<ConversionPanel
transformer={transformer}
editorTitle="JSON"
editorLanguage="json"
resultTitle="TOML"
resultLanguage={"toml"}
/>
);
}
+21
View File
@@ -0,0 +1,21 @@
import ConversionPanel from "@components/ConversionPanel";
import { useCallback } from "react";
import * as React from "react";
import { parse } from "@iarna/toml";
export default function TomlToJson() {
const transformer = useCallback(
({ value }) => Promise.resolve(JSON.stringify(parse(value))),
[]
);
return (
<ConversionPanel
transformer={transformer}
editorTitle="TOML"
editorLanguage="toml"
resultTitle="JSON"
resultLanguage={"json"}
/>
);
}
+14 -1
View File
@@ -135,6 +135,12 @@ export const categorizedRoutes = [
path: "/json-to-json-schema",
packageUrl: "https://www.npmjs.com/package/json_typegen_wasm",
packageName: "json_typegen_wasm"
},
{
label: "to TOML",
path: "/json-to-toml",
packageUrl: "https://www.npmjs.com/package/@iarna/toml",
packageName: "@iarna/toml"
}
]
},
@@ -151,7 +157,8 @@ export const categorizedRoutes = [
label: "to OpenAPI Schema",
path: "json-schema-to-openapi-schema",
packageName: "json-schema-to-openapi-schema",
packageUrl: "https://github.com/openapi-contrib/json-schema-to-openapi-schema"
packageUrl:
"https://github.com/openapi-contrib/json-schema-to-openapi-schema"
},
{
label: "to Protobuf",
@@ -332,6 +339,12 @@ export const categorizedRoutes = [
path: "/markdown-to-html",
packageName: "markdown",
packageUrl: "https://github.com/evilstreak/markdown-js"
},
{
label: "TOML to JSON",
path: "/toml-to-json",
packageUrl: "https://www.npmjs.com/package/@iarna/toml",
packageName: "@iarna/toml"
}
]
}
+5
View File
@@ -1018,6 +1018,11 @@
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.0.tgz#f3933a44e365864f4dad5db94158106d511e8131"
integrity sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==
"@iarna/toml@^2.2.5":
version "2.2.5"
resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c"
integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==
"@jsdevtools/ono@^7.1.3":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@jsdevtools/ono/-/ono-7.1.3.tgz#9df03bbd7c696a5c58885c34aa06da41c8543796"