fix: use js-yaml for both JSON to YAML and YAML to JSON (#2710)

This commit is contained in:
Bart van Andel 2026-08-06 11:52:18 +02:00 committed by GitHub
parent e2b0558c9c
commit 4290ea7539
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 81 additions and 10 deletions

79
package-lock.json generated
View File

@ -57,6 +57,7 @@
"jquery": "3.7.1", "jquery": "3.7.1",
"js-ascon": "^1.3.0", "js-ascon": "^1.3.0",
"js-sha3": "^0.12.0", "js-sha3": "^0.12.0",
"js-yaml": "^5.2.3",
"jsesc": "^3.1.0", "jsesc": "^3.1.0",
"json5": "^2.2.3", "json5": "^2.2.3",
"jsonata": "^2.2.2", "jsonata": "^2.2.2",
@ -2813,6 +2814,29 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/@eslint/eslintrc/node_modules/js-yaml": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz",
"integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/nodeca"
}
],
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/@eslint/js": { "node_modules/@eslint/js": {
"version": "9.39.5", "version": "9.39.5",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.5.tgz", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.5.tgz",
@ -7363,6 +7387,29 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/cosmiconfig/node_modules/js-yaml": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz",
"integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/nodeca"
}
],
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/crc-32": { "node_modules/crc-32": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz",
@ -12489,10 +12536,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/js-yaml": { "node_modules/js-yaml": {
"version": "4.3.0", "version": "5.2.3",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.0.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.2.3.tgz",
"integrity": "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==", "integrity": "sha512-n+mUVyUX5bVv7G/G2zyIHOhdxfuU1dY2NOFzTQUWiMUbFss8b57NFlgCCaggU78wSw5KVS9cllzeLyzyR+n5nw==",
"dev": true,
"funding": [ "funding": [
{ {
"type": "github", "type": "github",
@ -12508,7 +12554,7 @@
"argparse": "^2.0.1" "argparse": "^2.0.1"
}, },
"bin": { "bin": {
"js-yaml": "bin/js-yaml.js" "js-yaml": "bin/js-yaml.mjs"
} }
}, },
"node_modules/jsdoc-type-pratt-parser": { "node_modules/jsdoc-type-pratt-parser": {
@ -13622,6 +13668,29 @@
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/mocha/node_modules/js-yaml": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz",
"integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/nodeca"
}
],
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/mocha/node_modules/minimatch": { "node_modules/mocha/node_modules/minimatch": {
"version": "5.1.9", "version": "5.1.9",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz",

View File

@ -142,6 +142,7 @@
"jquery": "3.7.1", "jquery": "3.7.1",
"js-ascon": "^1.3.0", "js-ascon": "^1.3.0",
"js-sha3": "^0.12.0", "js-sha3": "^0.12.0",
"js-yaml": "^5.2.3",
"jsesc": "^3.1.0", "jsesc": "^3.1.0",
"json5": "^2.2.3", "json5": "^2.2.3",
"jsonata": "^2.2.2", "jsonata": "^2.2.2",

View File

@ -6,7 +6,7 @@
import Operation from "../Operation.mjs"; import Operation from "../Operation.mjs";
import OperationError from "../errors/OperationError.mjs"; import OperationError from "../errors/OperationError.mjs";
import YAML from "yaml"; import { dump } from "js-yaml";
/** /**
* JSON to YAML operation * JSON to YAML operation
@ -35,9 +35,9 @@ class JSONtoYAML extends Operation {
*/ */
run(input, args) { run(input, args) {
try { try {
return YAML.stringify(input); return dump(input);
} catch (err) { } catch (err) {
throw new OperationError("Test"); throw new OperationError("Unable to stringify YAML: " + err);
} }
} }

View File

@ -6,7 +6,8 @@
import Operation from "../Operation.mjs"; import Operation from "../Operation.mjs";
import OperationError from "../errors/OperationError.mjs"; import OperationError from "../errors/OperationError.mjs";
import jsYaml from "js-yaml"; import { load } from "js-yaml";
/** /**
* YAML to JSON operation * YAML to JSON operation
*/ */
@ -34,7 +35,7 @@ class YAMLToJSON extends Operation {
*/ */
run(input, args) { run(input, args) {
try { try {
return jsYaml.load(input); return load(input);
} catch (err) { } catch (err) {
throw new OperationError("Unable to parse YAML: " + err); throw new OperationError("Unable to parse YAML: " + err);
} }