feat: add Raw option for Jq operation
This commit is contained in:
parent
d9dacf6b8f
commit
b1369c97f0
@ -30,7 +30,12 @@ class Jq extends Operation {
|
|||||||
name: "Query",
|
name: "Query",
|
||||||
type: "string",
|
type: "string",
|
||||||
value: ""
|
value: ""
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
name: "Raw",
|
||||||
|
type: "boolean",
|
||||||
|
value: false
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +45,7 @@ class Jq extends Operation {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [query] = args;
|
const [query, raw] = args;
|
||||||
let result;
|
let result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -48,9 +53,12 @@ class Jq extends Operation {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new OperationError(`Invalid jq expression: ${err.message}`);
|
throw new OperationError(`Invalid jq expression: ${err.message}`);
|
||||||
}
|
}
|
||||||
|
if (raw && typeof result === 'string') {
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
return JSON.stringify(result);
|
return JSON.stringify(result);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user