From 01e4f9bb2f9bfe6a4ee95b9106f506cf2e7a47dc Mon Sep 17 00:00:00 2001 From: depperm Date: Sun, 16 Feb 2025 15:16:33 -0500 Subject: [PATCH] update to remove un-needed replace --- package-lock.json | 2 +- package.json | 2 +- src/core/operations/JSONToYAML.mjs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index a53c4f1f..5c2b05b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -96,7 +96,7 @@ "vkbeautify": "^0.99.3", "xpath": "0.0.34", "xregexp": "^5.1.1", - "yaml": "^2.2.1", + "yaml": "^2.7.0", "zlibjs": "^0.3.1" }, "devDependencies": { diff --git a/package.json b/package.json index d6647041..d0424af5 100644 --- a/package.json +++ b/package.json @@ -181,7 +181,7 @@ "vkbeautify": "^0.99.3", "xpath": "0.0.34", "xregexp": "^5.1.1", - "yaml": "^2.2.1", + "yaml": "^2.7.0", "zlibjs": "^0.3.1" }, "scripts": { diff --git a/src/core/operations/JSONToYAML.mjs b/src/core/operations/JSONToYAML.mjs index 7f6e17f2..833ea9dc 100644 --- a/src/core/operations/JSONToYAML.mjs +++ b/src/core/operations/JSONToYAML.mjs @@ -36,8 +36,8 @@ class JSONToYAML extends Operation { run(input, args) { const doc = new YAML.Document(); try { - doc.contents = JSON.parse(input.replace(/(\w+):/gm, `"$1":`)); - return doc.toString(); + doc.contents = YAML.stringify(JSON.parse(input)); + return doc.toString().replace(/^\|\n/, ""); } catch (err) { throw new OperationError("Unable to parse JSON to YAML: " + err.toString()); }