Skip to content

Commit

Permalink
feat: json to -ts 使用原始的数据结构
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGaoGang committed Nov 30, 2021
1 parent 002cb7c commit 3e4a65b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions packages/vscode-plugin-json-to-ts/lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ var vscode_1 = require("vscode");
var copyPaste = __importStar(require("copy-paste"));
var lodash_1 = __importDefault(require("lodash"));
var fs_1 = __importDefault(require("fs"));
var humps = require('humps');
function getClipboardText() {
try {
return Promise.resolve(copyPaste.paste());
Expand All @@ -44,7 +43,7 @@ exports.handleError = handleError;
function parseJson(json) {
var tryEval = function (str) { return eval("const a = " + str + "; a"); };
try {
return Promise.resolve(humps.camelizeKeys(JSON.parse(json)));
return Promise.resolve(JSON.parse(json));
}
catch (ignored) { }
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-plugin-json-to-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "json-2-ts",
"displayName": "json转ts",
"description": "Convert JSON object to typescript interfaces",
"version": "1.0.5",
"version": "1.0.6",
"publisher": "mrgaogang",
"icon": "icon.png",
"engines": {
Expand Down
3 changes: 1 addition & 2 deletions packages/vscode-plugin-json-to-ts/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as os from "os";
import * as copyPaste from "copy-paste";
import _ from "lodash";
import fs from 'fs'
const humps = require('humps');

export function getClipboardText() {
try {
Expand All @@ -21,7 +20,7 @@ export function parseJson(json: string): Promise<object> {
const tryEval = (str: any) => eval(`const a = ${str}; a`);

try {
return Promise.resolve(humps.camelizeKeys(JSON.parse(json)));
return Promise.resolve( JSON.parse(json));
} catch (ignored) {}

try {
Expand Down
Binary file not shown.

0 comments on commit 3e4a65b

Please sign in to comment.