jq Deprecated
Deprecated. Use JMESPath transformer from the Filters and Transformers content pack instead.
python · Community Common Scripts
Details
| ID | jq |
|---|---|
| Language | python |
| From Version | 6.1.0 |
| Docker Image | demisto/jq:1.0.0.113893 |
| Tags | transformer |
README
Run JQ Query.
Check these links:
- https://stedolan.github.io/jq/manual/#Invokingjq
- https://jqplay.org/
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | transformer |
Inputs
| Argument Name | Description |
|---|---|
| value | JSON String |
| query | JQ compatible query |
Outputs
| Path | Description | Type |
|---|---|---|
| jq.result | unknown |
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 import json import traceback import pyjq """ MAIN FUNCTION """ def jq_wrap(json_str, query): j = json.loads(json_str) res = pyjq.all(query, j) cmd_res = demisto.executeCommand("Set", {"key": "jq.result", "value": res}) if not is_error(cmd_res): return_results(res) def main(): try: jq_wrap(demisto.args()["value"], demisto.args()["query"]) except Exception as ex: demisto.error(traceback.format_exc()) # print the traceback return_error(f"Failed to execute jq. Error: {str(ex)}") if __name__ in ("__main__", "__builtin__", "builtins"): main()