← All skills

jq

Query, filter, transform, aggregate, and reshape JSON with the portable moonbit-community/jq WebAssembly CLI. Use when Codex needs jq-compatible field extraction, array filtering or mapping, object construction, raw or compact output, JSONL/NDJSON processing, or JSON transformations from stdin or files without relying on a native jq installation.

$ files
SKILL.md
SKILL.md

jq

Run the jq-compatible command directly from Mooncakes:

moonx moonbit-community/jq [OPTIONS] '<filter>' [FILE...]

Put options before the filter. Pass the filter as one single-quoted shell argument so $, pipes, parentheses, and quotes reach the command unchanged. When no file is supplied, provide JSON on standard input.

Workflow

  1. Inspect the input shape and decide whether it is one JSON value, a JSON file, or newline-delimited JSON.
  2. Write the smallest filter that produces the requested result.
  3. Choose -c for machine-readable compact JSON or -r when the result must be an unquoted string.
  4. Run the filter on representative input and check the exit status and output before using it in a larger pipeline.
  5. If a complex jq feature is unsupported, simplify the filter into smaller pipes and report the compatibility limitation instead of silently changing the requested transformation.

Common commands

Extract a field from standard input as raw text:

printf '%s' '{"user":{"name":"Moon"}}' \ | moonx moonbit-community/jq -r '.user.name // "unknown"'

Filter an array and construct smaller objects from a file:

moonx moonbit-community/jq -c \ '.items[] | select(.active) | {id: .id, name: .name}' data.json

Collect streaming results into one array:

moonx moonbit-community/jq -c '[.items[] | .id]' data.json

Transform and aggregate values:

moonx moonbit-community/jq -c '.values | map(. * 2) | add' data.json

Construct JSON without reading input:

moonx moonbit-community/jq -n -c '{ok: true, values: [1, 2]}'

Process newline-delimited JSON logs and skip invalid lines:

moonx moonbit-community/jq -l -r \ 'select(.level == "error") | .message' events.ndjson

Read a longer filter from a file:

moonx moonbit-community/jq -f transform.jq data.json

Options

  • Use -c or --compact-output to emit one compact JSON value per result.
  • Use -r or --raw-output to print string results without JSON quotes.
  • Use -n or --null-input to evaluate once with null input.
  • Use -l or --logs for JSONL/NDJSON and to skip non-JSON lines.
  • Use -f FILE or --from-file FILE to load the filter from a file.
  • Run moonx moonbit-community/jq --help to inspect the current command synopsis.

Prefer an explicit version such as moonbit-community/jq@0.2.0 in reproducible scripts. Use the unversioned moonbit-community/jq coordinate when automatically following the latest published version is desirable.

Skill
Name
moonbit-community/jq
Version
0.2.0
Published
yesterday
Versions
Download
Download ZIP

SHA-256

792a539d4eef260361d405974a0fcff2845895c512e7e03503e82a1d6c3d0538

Powered by MoonBit

Site sourceReport issueModulesSkillsBuild queueStatistics

© 2026 mooncakes.io