Expand description
oq - Object Query
A jq-like tool for querying JSON, YAML, TOML, and TOON data.
§Example
use oq::{compile_filter, run_filter, parse_auto, encode_to_format, Format};
use serde_json::json;
// Basic query
let filter = compile_filter(".name").unwrap();
let input = json!({"name": "Ada", "age": 30});
let results = run_filter(&filter, input).unwrap();
assert_eq!(results[0], json!("Ada"));
// Parse any format (auto-detected)
let yaml_input = "name: Ada\nage: 30";
let value = parse_auto(yaml_input).unwrap();
// Convert between formats
let toml_output = encode_to_format(&value, Format::Toml).unwrap();Structs§
- Chain
Mapper - Compose multiple mappers in sequence
- Compiled
Filter - A compiled jq filter
- Content
Formatter - Smart formatter that extracts long content into readable blocks
- Field
Format - Configuration for how to format specific fields
- Field
Select Mapper - Mapper that selects specific fields from objects
- Identity
Mapper - Identity mapper - passes through unchanged
- JqMapper
- A mapper that uses a jq filter expression
- Limit
Mapper - Mapper that limits array lengths
- Mapper
Registry - Registry of mappers by tool name pattern
- Truncate
Mapper - Mapper that truncates long strings
Enums§
- Format
- Internal format representation
- Input
Format - Supported input formats
- OqError
- Output
Format - Output format options
- Tool
Type - Tool types for smart formatting
Traits§
- Mapper
- Trait for transforming JSON before TOON encoding
Functions§
- command_
formatter - Create a formatter configured for command/shell output
- compile_
filter - Compile a jq filter expression
- default_
registry - Create a registry with common mappers for typical tool responses
- detect_
format - Auto-detect format based on content heuristics
- encode_
table - Encode an array of JSON objects as a compact TOON table
- encode_
to_ format - Convert a JSON value to the specified format
- format_
content - Format any string content - parses as JSON if possible, then formats as TOON
- format_
content_ smart - Format any string content with smart extraction
- format_
tool_ response - Format a JSON value as TOON, with fallback to JSON string on error
- format_
tool_ response_ smart - Format a JSON value as TOON with smart content extraction
- format_
tool_ response_ with - Format a tool response with a specific formatter type
- json_
to_ toon - Convert a JSON value to TOON string
- json_
to_ toon_ with_ mapper - Convert a JSON value to TOON string, applying a mapper first
- parse_
auto - Parse input with auto-detection
- parse_
input - Parse input in the detected format
- read_
note_ formatter - Create a formatter configured for read_note tool responses
- run_
filter - Run a compiled filter on a JSON value
- search_
formatter - Create a formatter configured for search tool responses
- to_json
- Convert a JSON value to JSON string
- to_toml
- Convert a JSON value to TOML string
- to_toon
- Convert a JSON value to TOON string
- to_yaml
- Convert a JSON value to YAML string
- try_
parse_ json - Try to parse a string as JSON, returning the parsed value or the original string