jq Package
ModularPipelines.Jq provides strongly typed access to the jq JSON processor CLI.
Installation
dotnet add package ModularPipelines.Jq
The jq executable must be installed and available on PATH when the pipeline runs.
Process JSON
using ModularPipelines.Context;
using ModularPipelines.Jq.Options;
using ModularPipelines.Models;
var result = await context.Tools.Jq.ExecuteAsync(
new JqExecuteOptions
{
RawOutput = true,
Indent = 2,
Arg = [new CliValuePair("environment", "production")],
Filter = ".deployments[] | select(.environment == $environment)",
InputFiles = ["deployments.json"],
},
cancellationToken: cancellationToken);
This renders:
jq --raw-output --indent 2 --arg environment production \
'.deployments[] | select(.environment == $environment)' deployments.json
Filter and input values are emitted after options. jq options taking a name/value pair—such as
--arg, --argjson, --slurpfile, and --rawfile—use CliValuePair so both values become
separate command-line arguments.