From 3f80795d932058eada1de489c1de815bd6a3fb5d Mon Sep 17 00:00:00 2001 From: p-racoon Date: Sun, 20 Oct 2019 18:27:04 +0530 Subject: [PATCH] temp json-to-rubyhash --- pages/ruby-hash-to-json.tsx | 32 ++++++++++++++++++++++++++++++++ static/monaco/html.worker.js | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 pages/ruby-hash-to-json.tsx diff --git a/pages/ruby-hash-to-json.tsx b/pages/ruby-hash-to-json.tsx new file mode 100644 index 0000000..e8e6694 --- /dev/null +++ b/pages/ruby-hash-to-json.tsx @@ -0,0 +1,32 @@ +import * as React from "react"; +import { useCallback } from "react"; +import ConversionPanel from "@components/ConversionPanel"; + +export default function() { + const transformer = useCallback(async ({ value }) => { + return JSON.stringify( + eval( + "(" + + value + .replace("=>", ":") + .replace(":", "") + .replace(/"/g, '\\"') // escape double quotes + .replace(/([a-zA-Z0-9_]+?):/g, '"$1":') // double quote keys + .replace(/'(.+?)'(,| })/g, '"$1"$2') + // double quote values + ")" + ), + null, + 2 + ); + }, []); + + return ( + + ); +} diff --git a/static/monaco/html.worker.js b/static/monaco/html.worker.js index 3909bea..880e938 100644 --- a/static/monaco/html.worker.js +++ b/static/monaco/html.worker.js @@ -13092,7 +13092,7 @@ function js_beautify(js_source_text, options) { /*!******************************************************************************************************************!*\ !*** ./node_modules/monaco-editor/esm/vs/language/html/_deps/vscode-html-languageservice/htmlLanguageService.js ***! \******************************************************************************************************************/ -/*! exports provided: getLanguageService, newHTMLDataProvider, SelectionRangeKind, TokenType, ScannerState, Position, Range, Location, LocationLink, Color, ColorInformation, ColorPresentation, FoldingRangeKind, FoldingRange, DiagnosticRelatedInformation, DiagnosticSeverity, Diagnostic, Command, TextEdit, TextDocumentEdit, CreateFile, RenameFile, DeleteFile, WorkspaceEdit, WorkspaceChange, TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem, MarkupKind, MarkupContent, CompletionItemKind, InsertTextFormat, CompletionItem, CompletionList, MarkedString, Hover, ParameterInformation, SignatureInformation, DocumentHighlightKind, DocumentHighlight, SymbolKind, SymbolInformation, DocumentSymbol, CodeActionKind, CodeActionContext, CodeAction, CodeLens, FormattingOptions, DocumentLink, EOL, TextDocument, TextDocumentSaveReason */ +/*! exports provided: Position, Range, Location, LocationLink, Color, ColorInformation, ColorPresentation, FoldingRangeKind, FoldingRange, DiagnosticRelatedInformation, DiagnosticSeverity, Diagnostic, Command, TextEdit, TextDocumentEdit, CreateFile, RenameFile, DeleteFile, WorkspaceEdit, WorkspaceChange, TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem, MarkupKind, MarkupContent, CompletionItemKind, InsertTextFormat, CompletionItem, CompletionList, MarkedString, Hover, ParameterInformation, SignatureInformation, DocumentHighlightKind, DocumentHighlight, SymbolKind, SymbolInformation, DocumentSymbol, CodeActionKind, CodeActionContext, CodeAction, CodeLens, FormattingOptions, DocumentLink, EOL, TextDocument, TextDocumentSaveReason, getLanguageService, newHTMLDataProvider, SelectionRangeKind, TokenType, ScannerState */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict";