| Crates.io | oq |
| lib.rs | oq |
| version | 0.1.0 |
| created_at | 2025-12-27 17:10:04.414277+00 |
| updated_at | 2025-12-27 17:10:04.414277+00 |
| description | Object Query - jq for JSON, YAML, TOML, and TOON |
| homepage | |
| repository | https://github.com/Mootikins/oq |
| max_upload_size | |
| id | 2007508 |
| size | 123,524 |
A jq-like tool for querying and transforming JSON, YAML, TOML, and TOON data.
cargo install oq
# Query JSON (like jq)
echo '{"name": "Ada"}' | oq '.name'
# Output: "Ada"
# Query YAML (auto-detected)
cat config.yaml | oq '.database.host'
# Query TOML
oq '.package.name' Cargo.toml
# Output: "oq"
# Convert formats
cat data.yaml | oq -o json # YAML -> JSON
cat data.json | oq -o yaml # JSON -> YAML
cat data.json | oq -o toml # JSON -> TOML
# Query and convert
oq '.users[]' data.yaml -o json
# Raw string output (no quotes)
oq -r '.name' data.json
Usage: oq [OPTIONS] [FILTER] [FILE]...
Arguments:
[FILTER] jq filter expression (default: ".")
[FILE]... Input files (reads from stdin if not specified)
Options:
-i, --input <FORMAT> Input format (auto, json, yaml, toml, toon)
-o, --output <FORMAT> Output format (json, yaml, toml, toon)
-r, --raw Output raw strings without quotes
-c, --compact Compact output (no pretty-printing)
-s, --slurp Read entire input as single array
-n, --null-input Don't read input, use null
--color <WHEN> Colorize output (auto, always, never)
-h, --help Print help
-V, --version Print version
| Format | Extensions | Description |
|---|---|---|
| JSON | .json |
JavaScript Object Notation |
| YAML | .yaml, .yml |
YAML Ain't Markup Language |
| TOML | .toml |
Tom's Obvious Minimal Language |
| TOON | .toon |
Text Object-Oriented Notation |
# Get package name
oq '.package.name' Cargo.toml
# Get all dependencies
oq '.dependencies | keys' Cargo.toml
# Get dependency versions
oq '.dependencies | to_entries | .[] | "\(.key): \(.value)"' Cargo.toml -r
# YAML config to JSON
oq '.' config.yaml -o json > config.json
# JSON API response to YAML
curl -s https://api.example.com/data | oq -o yaml
# Extract and convert
oq '.items' data.json -o yaml
oq uses jaq for jq-compatible filtering:
# Identity (output as-is)
oq '.'
# Select field
oq '.name'
# Array index
oq '.[0]'
# Iterate array
oq '.[]'
# Filter
oq '.[] | select(.active == true)'
# Map
oq '.users | map(.name)'
# Combine
oq '.items[] | {name, price}'
use oq::{parse_auto, compile_filter, run_filter, encode_to_format, Format};
// Parse any format
let value = parse_auto(r#"{"name": "Ada"}"#)?;
// Query with jq expression
let filter = compile_filter(".name")?;
let results = run_filter(&filter, value)?;
// Convert to another format
let yaml = encode_to_format(&results[0], Format::Yaml)?;
MIT OR Apache-2.0