FEATURE: Format Filters
| Field | Value |
|---|---|
| Version | 20261028 V1 |
| Description | Encode and decode values with jq format filters. |
| Depends On | FEATURE-Strings.md |
| Provides | jq format filters |
| Consumes | jq string and regex builtins |
Purpose
Provide jq's text, JSON, HTML, URI, CSV, TSV, shell, and Base64 formats as described in sources/jq-manual.txt. Formatting is triggered by a format filter or a formatted string in a jq program.
Behavior
@textuses jq string conversion and@jsonserializes JSON. HTML formatting escapes the five specified HTML characters.- URI and Base64 filters encode their inputs;
@uridand@base64ddecode their respective encodings. Preserve UTF-8 behavior. - CSV and TSV accept arrays and apply jq's field quoting and escaping rules. Shell formatting produces POSIX shell-escaped values.
- In a formatted string, retain literal text and apply the selected format to each interpolated result. Preserve generator multiplicity and order.
- Invalid inputs raise jq runtime errors. Follow the manual and the relevant corpus cases, including interactions with interpolation.
Programmatic Acceptance
=== AC formats-corpus ===
Intent: Format filters execute the corpus cases that exercise their encoding and interpolation behavior.
Suite: scoped
Requires: executable=python3; scope=test
Probe: --list
Probe Count: summary
import json import os import subprocess import sys
SELECT = r"@(?:text|json|html|uri|urid|csv|tsv|sh|base64d?)\b" result = subprocess.run( [sys.executable, "sources/run_conformance.py", "--select", SELECT, "--json"], capture_output=True, text=True, env={**os.environ, "JQ": os.path.abspath("jq")}, ) print(result.stdout) print(result.stderr, file=sys.stderr) report = json.loads(result.stdout) tally = report["summary"] assert sum(tally.values()) > 0, f"selector matched no case: {SELECT}" assert tally["fail"] == 0 and tally["error"] == 0, tally assert result.returncode == 0, result.returncode === END AC formats-corpus ===
User Acceptance
- None.
Guardrails
- Use only the Python standard library and do not invoke a system jq or third-party jq implementation.
- Do not alter staged source assets.