From a1ade8242016d1985d3038b38ded10a09204a022 Mon Sep 17 00:00:00 2001 From: Roman Karwacik Date: Wed, 11 Mar 2026 13:34:19 +0100 Subject: [PATCH] feat: add Raw option for Jq operation --- src/core/operations/Jq.mjs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/core/operations/Jq.mjs b/src/core/operations/Jq.mjs index 4584d1a98..38906fbe8 100644 --- a/src/core/operations/Jq.mjs +++ b/src/core/operations/Jq.mjs @@ -30,7 +30,12 @@ class Jq extends Operation { name: "Query", type: "string", value: "" - } + }, + { + name: "Raw", + type: "boolean", + value: false + }, ]; } @@ -41,12 +46,20 @@ class Jq extends Operation { */ run(input, args) { return (async () => { - const [query] = args; - try { - const result = await jq.json(input, query); - return JSON.stringify(result); - } catch (err) { - throw new OperationError(`Invalid jq expression: ${err.message}`); + const [query, raw] = args; + if (raw) { + const result = await jq.raw(input, query, ["-r"]); + if (result.stderr !== "") { + throw new OperationError(`Invalid jq expression: ${result.stderr}`); + } + return result.stdout; + } else { + try { + const result = await jq.json(input, query); + return JSON.stringify(result); + } catch (err) { + throw new OperationError(`Invalid jq expression: ${err.message}`); + } } })(); }