JQ Transformations
Apiary includes a powerful JQ processor for filtering, transforming, and manipulating JSON data.
Creating a JQ Request
- Click File → New Request and select JQ
- Provide JSON input (or select from another request's output)
- Write JQ query
- View transformed output
Input Sources
Direct Input
Paste or type JSON directly into the input editor.
From Request Response
Select output from another request as input for JQ transformation.
From File
Load JSON from a local file.
JQ Editor
Query Syntax
Write JQ queries using the full JQ language syntax:
- Basic filter:
.(identity) - Field access:
.field,.field.subfield - Array iteration:
.[],.[0],.[:5] - Object construction:
{key: value} - Functions:
length,keys,map,select, etc.
Auto-completion
Apiary provides JQ function and syntax suggestions.
Multiple Queries
Separate multiple queries with newlines; each produces independent output.
Performing Transformations
Click Perform to execute the JQ query. The transformed output appears in the right panel.
Output Display
Formatted JSON
Output is pretty-printed with syntax highlighting and collapsible sections.
Raw Output
Toggle between formatted and raw output views.
Multiple Results
If the query produces multiple results, they are displayed as separate items.
Example: Basic Filtering
Input JSON:
{
"users": [
{"id": 1, "name": "Alice", "active": true},
{"id": 2, "name": "Bob", "active": false},
{"id": 3, "name": "Charlie", "active": true}
]
}JQ query:
.users[] | select(.active == true) | {id, name}Output:
{"id": 1, "name": "Alice"}
{"id": 3, "name": "Charlie"}Example: Data Transformation
# Group users by active status
.users | group_by(.active) | map({status: (if .[0].active then "active" else "inactive" end), count: length, users: map(.name)})Advanced Features
Variable Binding
Use as for variable binding in complex queries.
Modules
Import JQ modules for extended functionality.
Streaming
Process large JSON inputs with streaming mode.
Error Handling
JQ errors are displayed with line numbers and helpful messages.
Integration with Other Requests
JQ can be used as a post-processing step for any JSON response:
- Perform an HTTP request that returns JSON
- Click the JQ button in the response toolbar
- Write JQ query to filter the response
- View filtered results inline
Performance Tips
- Use streaming mode for large inputs
- Apply filters early in the pipeline
- Use
--compact-outputfor machine-readable output