How to use the jq.icon_jq.actions.run_jq.schema.Output.JSON_OUT function in jq

To help you get started, we’ve selected a few jq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rapid7 / insightconnect-plugins / jq / icon_jq / actions / run_jq / action.py View on Github external
jq_cmd_array.append(filter_)

        self.logger.info("Command to Run: {}".format(jq_cmd_array))
        process = subprocess.Popen(jq_cmd_array, stdout=PIPE, stderr=PIPE, stdin=PIPE)
        std_out, std_err = process.communicate(input=json.dumps(json_in).encode(), timeout=timeout)
        return_code = process.returncode

        self.logger.info("Return Code: {}".format(return_code))
        if return_code > 0:
            self.logger.info("JQ Standard Output: {}".format(std_out.decode()))
            self.logger.info("JQ Standard Error: {}".format(std_err.decode()))
            raise Exception("JQ failed with return code: {}".format(return_code))

        output_string = std_out.decode('utf-8').strip()
        return {Output.JSON_OUT: output_string}