§JMESPath Extensions
A comprehensive collection of 400+ extension functions for JMESPath queries.
§Built on jmespath.rs
This crate extends the jmespath crate by
@mtdowling, which provides the complete Rust implementation
of the JMESPath specification. All spec-compliant
parsing, evaluation, and the 26 built-in functions come from that foundational library—we
simply add extra functions on top.
If you only need standard JMESPath functionality, use jmespath directly.
§Non-Standard Extension Warning
These functions are NOT part of the JMESPath specification.
Queries using these extension functions will NOT work in other JMESPath
implementations (Python, JavaScript, Go, etc.). If you need portable queries,
use only the 26 standard JMESPath built-in functions:
abs, avg, ceil, contains, ends_with, floor, join, keys,
length, map, max, max_by, merge, min, min_by, not_null,
reverse, sort, sort_by, starts_with, sum, to_array, to_number,
to_string, type, values
These extensions are useful when:
- You control both the query author and the runtime environment
- You need functionality beyond standard JMESPath
- Cross-implementation compatibility is not required
§JEP Alignment
Some functions in this library align with JMESPath Enhancement Proposals (JEPs),
which are draft specifications for extending JMESPath. While JEPs are not yet part of the
official specification, aligning with them improves compatibility with other implementations
that adopt the same proposals.
§JEP-013: Object Manipulation Functions
The following functions implement JEP-013:
| Function | Signature | Description |
items | items(object) → array[array] | Returns [[key, value], ...] pairs |
from_items | from_items(array) → object | Converts [[key, value], ...] to object |
zip | zip(array1, array2) → array | Zips two arrays into pairs |
§JEP-014: String Functions
The following functions implement JEP-014:
| Function | Signature | Description |
find_first | find_first(string, sub, start?, end?) → number|null | Find first occurrence |
find_last | find_last(string, sub, start?, end?) → number|null | Find last occurrence |
lower | lower(string) → string | Convert to lowercase |
upper | upper(string) → string | Convert to uppercase |
trim | trim(string, chars?) → string | Remove leading/trailing chars |
trim_left | trim_left(string, chars?) → string | Remove leading chars |
trim_right | trim_right(string, chars?) → string | Remove trailing chars |
pad_left | pad_left(string, width, pad?) → string | Left-pad to width |
pad_right | pad_right(string, width, pad?) → string | Right-pad to width |
replace | replace(string, old, new, count?) → string | Replace occurrences |
split | split(string, sep, count?) → array | Split into array |
Note: Some JEP-014 functions in this library have slight signature differences
(e.g., required vs optional parameters). See individual function documentation for details.
§Quick Start
use jmespath::{Runtime, Variable};
use jmespath_extensions::register_all;
let mut runtime = Runtime::new();
runtime.register_builtin_functions();
register_all(&mut runtime);
let expr = runtime.compile("upper(@)").unwrap();
let data = Variable::String("hello".to_string());
let result = expr.search(&data).unwrap();
assert_eq!(result.as_string().unwrap(), "HELLO");
§Working with JSON Data
Most real-world usage involves querying JSON data:
use jmespath::{Runtime, Variable};
use jmespath_extensions::register_all;
let mut runtime = Runtime::new();
runtime.register_builtin_functions();
register_all(&mut runtime);
let json = r#"{
"users": [
{"name": "alice", "email": "ALICE@EXAMPLE.COM"},
{"name": "bob", "email": "BOB@EXAMPLE.COM"}
]
}"#;
let data = Variable::from_json(json).unwrap();
let expr = runtime.compile("users[*].{name: upper(name), email: lower(email)}").unwrap();
let result = expr.search(&data).unwrap();
§Feature Flags
This crate uses feature flags to control which functions are included.
This allows you to minimize dependencies and binary size.
| Feature | Dependencies | Description |
full (default) | all | All functions |
core | none | String, array, object, math, type, utility, path |
string | none | String manipulation |
array | none | Array operations |
object | none | Object utilities |
math | none | Mathematical operations |
type | none | Type conversion and checking |
utility | none | Utility functions |
path | none | Path manipulation |
validation | none | Validation functions |
hash | md-5, sha1, sha2, crc32fast | Hash functions |
encoding | base64, hex | Encoding functions |
url | url | URL functions |
regex | regex | Regex functions |
uuid | uuid | UUID generation |
rand | rand | Random functions |
datetime | chrono | Date/time functions |
fuzzy | strsim | Fuzzy matching functions |
expression | none | Expression-based functions |
phonetic | rphonetic | Phonetic encoding functions |
geo | geoutils | Geospatial functions |
semver | semver | Semantic versioning |
network | ipnetwork | Network/IP functions |
ids | nanoid, ulid | ID generation |
text | none | Text analysis |
duration | none | Duration parsing |
color | none | Color manipulation |
computing | none | Computing utilities |
jsonpatch | json-patch | JSON Patch functions |
multi-match | aho-corasick | Multi-pattern matching |
discovery | strsim | Discovery/search functions |
§Using Specific Features
# Only include string and array functions (no external dependencies)
[dependencies]
jmespath_extensions = { version = "0.1", default-features = false, features = ["string", "array"] }
# Include core functions plus regex
[dependencies]
jmespath_extensions = { version = "0.1", default-features = false, features = ["core", "regex"] }
§Module Overview
See each module’s documentation for detailed function reference with examples:
string - String manipulation (upper, lower, split, replace, camel_case, etc.)
array - Array operations (first, last, unique, chunk, zip, range, etc.)
object - Object utilities (items, pick, omit, deep_merge, etc.)
math - Math operations (round, sqrt, pow, median, sin, cos, etc.)
type_conv - Type functions (type_of, is_string, is_empty, to_number, etc.)
utility - Utilities (default, if, coalesce, json_encode, etc.)
datetime - Date/time (now, now_millis, parse_date, format_date, date_add, date_diff)
fuzzy - Fuzzy matching (levenshtein, jaro_winkler, sorensen_dice, etc.)
expression - Expression functions (map_expr, filter_expr, any_expr, all_expr, find_expr, sort_by_expr)
path - Path functions (path_basename, path_dirname, path_ext, path_join)
validation - Validation (is_email, is_url, is_uuid, is_ipv4, is_ipv6)
hash - Hashing (md5, sha1, sha256, crc32)
encoding - Encoding (base64_encode, base64_decode, hex_encode, hex_decode)
url_fns - URL functions (url_encode, url_decode, url_parse)
regex_fns - Regex (regex_match, regex_extract, regex_replace)
random - Random (random, shuffle, sample, uuid)
phonetic - Phonetic encoding (soundex, metaphone, double_metaphone, nysiis, sounds_like)
geo - Geospatial (haversine, haversine_km, haversine_mi, bearing)
semver_fns - Semantic versioning (semver_parse, semver_compare, semver_matches, is_semver)
network - Network/IP (ip_to_int, int_to_ip, cidr_contains, cidr_network, is_private_ip)
ids - ID generation (nanoid, ulid, ulid_timestamp)
text - Text analysis (word_count, char_count, reading_time, word_frequencies)
duration - Duration parsing (parse_duration, format_duration)
color - Color manipulation (hex_to_rgb, rgb_to_hex, lighten, darken, color_mix)
computing - Computing utilities (parse_bytes, format_bytes, bit_and, bit_or, bit_xor)
jsonpatch - JSON Patch (RFC 6902) and Merge Patch (RFC 7396) (json_patch, json_merge_patch, json_diff)
§Quick Reference (419 functions)
Click any function name to jump to its detailed documentation in the functions module.
| Function | Signature | Description |
chunk | array, number -> array | Split array into chunks of size n |
compact | array -> array | Remove null values from array |
difference | array, array -> array | Elements in first array not in second |
drop | array, number -> array | Drop first n elements |
find_index | array, any -> number | null | Find index of value in array |
first | array -> any | Get first element of array |
flatten | array -> array | Flatten array one level deep |
flatten_deep | array -> array | Recursively flatten nested arrays |
frequencies | array -> object | Count occurrences of each value |
group_by | array, string -> object | Group array elements by key |
index_by | array, string -> object | Create lookup map from array using key field (last value wins for duplicates) |
includes | array, any -> boolean | Check if array contains value |
index_at | array, number -> any | Get element at index (supports negative) |
intersection | array, array -> array | Elements common to both arrays |
last | array -> any | Get last element of array |
pairwise | array -> array | Return adjacent pairs from array |
range | number, number -> array | Generate array of numbers |
sliding_window | array, number -> array | Create overlapping windows of size n (alias for window) |
take | array, number -> array | Take first n elements |
transpose | array -> array | Transpose a 2D array (swap rows and columns) |
union | array, array -> array | Unique elements from both arrays |
unique | array -> array | Remove duplicate values |
zip | array, array -> array | Zip two arrays together |
indices_array | array, any -> array | Find all indices where a value appears in an array (jq parity) |
inside_array | array, array -> boolean | Check if all elements of first array are contained in second array (inverse of contains, jq parity) |
bsearch | array, any -> number | Binary search in a sorted array, returns index or negative insertion point (jq parity) |
cartesian | array, array? -> array | Compute cartesian product of arrays (jq parity for N-way product) |
butlast | array -> array | Return all elements except the last (alias for initial) |
interpose | array, any -> array | Insert separator value between each element of array |
zipmap | array, array -> object | Create object from parallel arrays of keys and values |
partition_by | array, string -> array | Split array into partitions when field value changes (preserves order unlike group_by) |
dedupe | array -> array | Remove consecutive duplicate values (unlike unique, allows non-adjacent duplicates) |
repeat_array | any, number -> array | Create array with value repeated n times |
cycle | array, number -> array | Cycle through array elements n times |
| Function | Signature | Description |
color_complement | string -> string | Get complementary color |
color_grayscale | string -> string | Convert to grayscale |
color_invert | string -> string | Invert a color |
color_mix | string, string, number -> string | Mix two colors |
darken | string, number -> string | Darken a color by percentage |
hex_to_rgb | string -> object | Convert hex color to RGB |
lighten | string, number -> string | Lighten a color by percentage |
rgb_to_hex | number, number, number -> string | Convert RGB to hex color |
| Function | Signature | Description |
business_days_between | number, number -> number | Count business days (weekdays) between two timestamps |
date_add | number, number, string -> number | Add time to timestamp |
date_diff | number, number, string -> number | Difference between timestamps |
duration_since | number|string -> object | Get detailed duration object from timestamp to now |
end_of_day | number|string -> string | Get ISO 8601 string for end of day (23:59:59) |
epoch_ms | -> number | Current Unix timestamp in milliseconds (alias for now_ms) |
format_date | number, string -> string | Format timestamp to string |
from_epoch | number -> string | Convert Unix timestamp (seconds) to ISO 8601 string |
from_epoch_ms | number -> string | Convert Unix timestamp (milliseconds) to ISO 8601 string |
is_after | number|string, number|string -> boolean | Check if first date is after second date (accepts timestamps or date strings) |
is_before | number|string, number|string -> boolean | Check if first date is before second date (accepts timestamps or date strings) |
is_between | number|string, number|string, number|string -> boolean | Check if date is between start and end (inclusive, accepts timestamps or date strings) |
is_same_day | number|string, number|string -> boolean | Check if two timestamps/dates are on the same day |
is_weekday | number -> boolean | Check if timestamp falls on weekday (Monday-Friday) |
is_weekend | number -> boolean | Check if timestamp falls on weekend (Saturday or Sunday) |
parse_date | string, string? -> number | Parse date string to timestamp |
quarter | number -> number | Get quarter of year (1-4) from timestamp |
relative_time | number -> string | Human-readable relative time from timestamp |
start_of_day | number|string -> string | Get ISO 8601 string for start of day (00:00:00) |
start_of_month | number|string -> string | Get ISO 8601 string for start of month |
start_of_week | number|string -> string | Get ISO 8601 string for start of week (Monday 00:00:00) |
start_of_year | number|string -> string | Get ISO 8601 string for start of year |
time_ago | number|string -> string | Human-readable time since date (accepts timestamps or date strings) |
timezone_convert | string, string, string -> string | Convert timestamp between timezones (IANA timezone names) |
to_epoch | number|string -> number | Convert date string or timestamp to Unix timestamp (seconds) |
to_epoch_ms | number|string -> number | Convert date string or timestamp to Unix timestamp (milliseconds) |
| Function | Signature | Description |
fuzzy_search | array, string|object, string -> array | Search an array of objects by multiple fields, returning matches sorted by relevance score |
fuzzy_match | string, string -> object | Check if a single string value matches a query, returning match details |
fuzzy_score | string, string -> number | Get the numeric match score between a value and query (higher is better match) |
| Function | Signature | Description |
base64_decode | string -> string | Decode base64 string |
base64_encode | string -> string | Encode string to base64 |
hex_decode | string -> string | Decode hex string |
hex_encode | string -> string | Encode string to hex |
jwt_decode | string -> object | Decode JWT payload (claims) without verification |
jwt_header | string -> object | Decode JWT header without verification |
html_escape | string -> string | Escape HTML special characters |
html_unescape | string -> string | Unescape HTML entities |
| Function | Signature | Description |
all_expr | array, expression -> boolean | Return true if every element satisfies the expression (short-circuits on false) |
any_expr | array, expression -> boolean | Return true if any element satisfies the expression (short-circuits) |
apply | object|string, ...any -> any | Apply a partial function or invoke a function by name with arguments |
count_by | string, array -> object | Count occurrences grouped by expression result |
count_expr | array, expression -> number | Count how many elements satisfy the expression |
drop_while | string, array -> array | Drop elements from array while expression is truthy |
every | string, array -> boolean | Check if all elements match (alias for all_expr) |
filter_expr | array, expression -> array | Keep elements where JMESPath expression evaluates to truthy value |
find_expr | array, expression -> any | Return first element where expression is truthy, or null if none match |
find_index_expr | array, expression -> number | null | Return zero-based index of first matching element, or -1 if none match |
flat_map_expr | array, expression -> array | Apply expression to each element and flatten all results into one array |
mapcat | string, array -> array | Apply expression to each element and concatenate all results (Clojure-style alias for flat_map_expr) |
group_by_expr | array, expression -> object | Group elements into object keyed by expression result |
map_expr | array, expression -> array | Apply a JMESPath expression to each element, returning transformed array |
map_keys | string, object -> object | Transform object keys using expression |
map_values | string, object -> object | Transform object values using expression |
max_by_expr | array, expression -> any | Return element with largest expression result, or null for empty array |
min_by_expr | array, expression -> any | Return element with smallest expression result, or null for empty array |
order_by | array, array[[string, string]] -> array | Sort array by multiple fields with ascending/descending control |
partial | string, ...any -> object | Create a partial function with some arguments pre-filled |
partition_expr | array, expression -> array | Split array into [matches, non-matches] based on expression |
reduce_expr | string, array, any -> any | Reduce array to single value using accumulator expression |
reject | string, array -> array | Keep elements where expression is falsy (inverse of filter_expr) |
scan_expr | string, array, any -> array | Like reduce but returns array of intermediate accumulator values |
reductions | string, array, any -> array | Return array of intermediate values from reduction (Clojure-style alias for scan_expr) |
none | string, array -> boolean | Return true if no elements satisfy the expression (opposite of any_expr/some) |
some | string, array -> boolean | Check if any element matches (alias for any_expr) |
sort_by_expr | array, expression -> array | Sort array by expression result in ascending order |
take_while | string, array -> array | Take elements from array while expression is truthy |
unique_by_expr | array, expression -> array | Remove duplicates by expression result, keeping first occurrence |
zip_with | string, array, array -> array | Zip two arrays with a custom combiner expression |
walk | string, any -> any | Recursively apply expression to all components of a value (bottom-up) |
recurse | any -> array | Collect all nested values recursively (jq parity) |
recurse_with | any, expression -> array | Recursive descent with expression filter (jq parity) |
while_expr | any, expression, expression -> array | Loop while condition is true, collecting intermediate values (jq parity) |
until_expr | any, expression, expression -> array | Loop until condition becomes true, collecting intermediate values (jq parity) |
| Function | Signature | Description |
to_csv | array -> string | Convert array to CSV row string (RFC 4180 compliant) |
to_tsv | array -> string | Convert array to TSV row string (tab-separated) |
to_csv_rows | array -> string | Convert array of arrays to multi-line CSV string |
to_csv_table | array, array? -> string | Convert array of objects to CSV with header row |
from_csv | string -> array | Parse CSV string into array of arrays (jq parity) |
from_tsv | string -> array | Parse TSV string into array of arrays (jq parity) |
| Function | Signature | Description |
damerau_levenshtein | string, string -> number | Damerau-Levenshtein distance |
jaro | string, string -> number | Jaro similarity (0-1) |
jaro_winkler | string, string -> number | Jaro-Winkler similarity (0-1) |
levenshtein | string, string -> number | Levenshtein edit distance |
normalized_levenshtein | string, string -> number | Normalized Levenshtein (0-1) |
sorensen_dice | string, string -> number | Sorensen-Dice coefficient (0-1) |
normalized_damerau_levenshtein | string, string -> number | Normalized Damerau-Levenshtein similarity (0-1) |
hamming | string, string -> number|null | Hamming distance (number of differing positions). Returns null if strings have different lengths |
osa_distance | string, string -> number | Optimal String Alignment distance (like Levenshtein but allows adjacent transpositions) |
| Function | Signature | Description |
geo_bearing | number, number, number, number -> number | Bearing between coordinates |
geo_distance | number, number, number, number -> number | Haversine distance in meters |
geo_distance_km | number, number, number, number -> number | Haversine distance in kilometers |
geo_distance_miles | number, number, number, number -> number | Haversine distance in miles |
| Function | Signature | Description |
crc32 | string -> number | Calculate CRC32 checksum |
hmac_md5 | string, string -> string | Calculate HMAC-MD5 signature |
hmac_sha1 | string, string -> string | Calculate HMAC-SHA1 signature |
hmac_sha256 | string, string -> string | Calculate HMAC-SHA256 signature |
hmac_sha512 | string, string -> string | Calculate HMAC-SHA512 signature |
md5 | string -> string | Calculate MD5 hash |
sha1 | string -> string | Calculate SHA-1 hash |
sha256 | string -> string | Calculate SHA-256 hash |
sha512 | string -> string | Calculate SHA-512 hash |
| Function | Signature | Description |
nanoid | number? -> string | Generate nanoid |
ulid | -> string | Generate ULID |
ulid_timestamp | string -> number | Extract timestamp from ULID |
| Function | Signature | Description |
json_diff | object, object -> array | Generate JSON Patch (RFC 6902) that transforms first object into second |
json_merge_patch | object, object -> object | Apply JSON Merge Patch (RFC 7396) to an object |
json_patch | object, array -> object | Apply JSON Patch (RFC 6902) operations to an object |
| Function | Signature | Description |
detect_language | string -> string | null | Detect the language of text, returning the native language name |
detect_language_iso | string -> string | null | Detect the language of text, returning the ISO 639-3 code |
detect_script | string -> string | null | Detect the script (writing system) of text |
detect_language_confidence | string -> number | null | Detect language and return confidence score (0.0-1.0) |
detect_language_info | string -> object | null | Detect language and return full detection info object |
| Function | Signature | Description |
abs_fn | number -> number | Absolute value |
add | number, number -> number | Add two numbers |
ceil_fn | number -> number | Round up to nearest integer |
clamp | number, number, number -> number | Clamp value to range |
cos | number -> number | Cosine function |
covariance | array, array -> number | Covariance between two arrays |
divide | number, number -> number | Divide first number by second |
ewma | array, number -> array | Exponential weighted moving average |
trend | array -> string | Detect trend direction in a numeric array (increasing, decreasing, or stable) |
trend_slope | array -> number | Calculate the linear regression slope of a numeric array |
rate_of_change | array -> array | Calculate percentage change between consecutive values |
cumulative_sum | array -> array | Calculate running cumulative sum of a numeric array |
floor_fn | number -> number | Round down to nearest integer |
format_number | number, number?, string? -> string | Format number with separators and optional suffix |
log | number -> number | Natural logarithm |
median | array -> number | Calculate median of array |
mod_fn | number, number -> number | Modulo operation |
mode | array -> any | Find the most common value in an array |
moving_avg | array, number -> array | Simple moving average with window size |
multiply | number, number -> number | Multiply two numbers |
percentile | array, number -> number | Calculate percentile of array |
pow | number, number -> number | Raise to power |
quantile | array, number -> number | Nth quantile (generalized percentile, q in [0,1]) |
round | number, number -> number | Round to specified decimal places |
sin | number -> number | Sine function |
sqrt | number -> number | Square root |
standardize | array -> array | Standardize array to mean=0, std=1 (z-score normalization) |
stddev | array -> number | Calculate standard deviation of array |
subtract | number, number -> number | Subtract second number from first |
tan | number -> number | Tangent function |
to_fixed | number, number -> string | Format number with exact decimal places |
variance | array -> number | Calculate variance of array |
quartiles | array -> object | Calculate quartiles (Q1, Q2, Q3) and IQR of array |
outliers_iqr | array, number? -> array | Find outliers using IQR method (values outside Q1-1.5IQR to Q3+1.5IQR) |
outliers_zscore | array, number? -> array | Find outliers using z-score method (values with |z-score| > threshold) |
| Function | Signature | Description |
extract_all | string, array[string] -> array[object] | Extract all pattern matches with positions (Aho-Corasick) |
extract_between | string, string, string -> string|null | Extract text between two delimiters |
match_all | string, array[string] -> boolean | Check if string contains all of the patterns (Aho-Corasick) |
match_any | string, array[string] -> boolean | Check if string contains any of the patterns (Aho-Corasick) |
match_count | string, array[string] -> number | Count total pattern matches in string (Aho-Corasick) |
match_positions | string, array[string] -> array[object] | Get start/end positions of all pattern matches (Aho-Corasick) |
match_which | string, array[string] -> array[string] | Return array of patterns that match the string (Aho-Corasick) |
replace_many | string, object -> string | Replace multiple patterns simultaneously (Aho-Corasick) |
split_keep | string, string -> array[string] | Split string keeping delimiters in result |
tokenize | string, object? -> array[string] | Smart word tokenization with optional lowercase and min_length |
| Function | Signature | Description |
cidr_broadcast | string -> string | Get broadcast address from CIDR |
cidr_contains | string, string -> boolean | Check if IP is in CIDR range |
cidr_network | string -> string | Get network address from CIDR |
cidr_prefix | string -> number | Get prefix length from CIDR |
int_to_ip | number -> string | Convert integer to IP address |
ip_to_int | string -> number | Convert IP address to integer |
is_private_ip | string -> boolean | Check if IP is in private range |
| Function | Signature | Description |
deep_diff | object, object -> object | Structural diff between two objects |
deep_equals | any, any -> boolean | Deep equality check for any two values |
deep_merge | object, object -> object | Recursively merge objects |
defaults | object, object -> object | Assign default values for missing keys (shallow) |
defaults_deep | object, object -> object | Recursively assign default values for missing keys |
delete_path | any, string -> any | Delete value at JSON pointer path (immutable) |
flatten | object -> object | Alias for flatten_keys - flatten nested object with dot notation keys |
flatten_array | any, string? -> object | Flatten nested objects and arrays with dot notation keys (arrays use numeric indices) |
flatten_keys | object -> object | Flatten nested object with dot notation keys |
from_items | array -> object | Convert array of [key, value] pairs to object |
from_entries | array -> object | Alias for from_items. Convert array of [key, value] pairs to object. Familiar to jq/lodash users. |
get | any, string, any? -> any | Get value at dot-separated path with optional default |
has | any, string -> boolean | Check if dot-separated path exists |
invert | object -> object | Swap keys and values |
items | object -> array | Convert object to array of [key, value] pairs |
with_entries | object, string -> object | Transform object entries using an expression (jq parity) |
leaves | any -> array | Get all leaf values (non-object, non-array) |
leaves_with_paths | any -> array | Get all leaf values with their JSON pointer paths |
omit | object, array -> object | Remove specific keys from object |
paths | any -> array | List all JSON pointer paths in value |
pick | object, array -> object | Select specific keys from object |
rename_keys | object, object -> object | Rename object keys |
set_path | any, string, any -> any | Set value at JSON pointer path (immutable) |
unflatten | object -> object | Alias for unflatten_keys - restore nested object from dot notation keys |
unflatten_keys | object -> object | Restore nested object from dot notation keys |
compact_deep | array -> array | Recursively compact arrays, removing nulls at all levels |
remove_empty | any -> any | Recursively remove nulls, empty strings, empty arrays, and empty objects |
remove_empty_strings | any -> any | Recursively remove empty string values |
remove_nulls | any -> any | Recursively remove null values |
completeness | object -> number | Calculate percentage of non-null fields (0-100) |
type_consistency | array -> object | Check if array elements have consistent types |
data_quality_score | any -> object | Analyze data quality and return score with detailed issues |
redact | any, array -> any | Recursively replace values at specified keys with [REDACTED] |
mask | string, number? -> string | Mask a string, showing only the last N characters |
redact_keys | any, string -> any | Recursively redact keys matching a regex pattern |
pluck_deep | any, string -> array | Find all values for a key anywhere in nested structure |
paths_to | any, string -> array | Find all dot-notation paths to a key anywhere in structure |
snake_keys | any -> any | Recursively convert all keys to snake_case |
camel_keys | any -> any | Recursively convert all keys to camelCase |
kebab_keys | any -> any | Recursively convert all keys to kebab-case |
structural_diff | any, any -> object | Compare two values and return their structural differences |
has_same_shape | any, any -> boolean | Check if two values have the same structure (ignoring actual values) |
infer_schema | any -> object | Infer a JSON Schema-like type description from a value |
chunk_by_size | array, number -> array | Split an array into chunks of approximately the specified byte size |
paginate | array, number, number -> object | Get a page of items from an array with metadata |
estimate_size | any -> number | Estimate the JSON serialization size in bytes |
truncate_to_size | array, number -> array | Truncate an array to fit within approximately the specified byte size |
template | object, string -> string | Expand a template string with values from an object using {{key}} syntax |
template_strict | object, string -> string | null | Expand a template string, returning null if any variable is missing |
| Function | Signature | Description |
path_basename | string -> string | Get filename from path |
path_dirname | string -> string | Get directory from path |
path_ext | string -> string | Get file extension |
path_join | string... -> string | Join path segments |
| Function | Signature | Description |
caverphone | string -> string | Caverphone code |
caverphone2 | string -> string | Caverphone 2 code |
double_metaphone | string -> object | Double Metaphone codes |
match_rating_codex | string -> string | Match Rating codex |
metaphone | string -> string | Metaphone phonetic code |
nysiis | string -> string | NYSIIS phonetic code |
phonetic_match | string, string, string -> boolean | Check phonetic match with algorithm |
soundex | string -> string | Soundex phonetic code |
sounds_like | string, string -> boolean | Check if strings sound similar |
| Function | Signature | Description |
random | -> number | Generate random number between 0 and 1 |
sample | array, number -> array | Random sample from array |
shuffle | array -> array | Randomly shuffle array |
| Function | Signature | Description |
regex_extract | string, string -> array | Extract regex matches. Use backtick-JSON syntax: regex_extract(text, "\\w+") |
regex_match | string, string -> boolean | Test if string matches regex. Use backtick-JSON syntax: regex_match(text, "^\\d+$") |
regex_replace | string, string, string -> string | Replace regex matches. Use backtick-JSON syntax: regex_replace(text, "\\d+", "X") |
| Function | Signature | Description |
abs | number -> number | Returns the absolute value of a number |
avg | array[number] -> number | Returns the average of an array of numbers |
ceil | number -> number | Returns the smallest integer greater than or equal to the number |
contains | array|string, any -> boolean | Returns true if the subject contains the search value |
ends_with | string, string -> boolean | Returns true if the subject ends with the suffix |
floor | number -> number | Returns the largest integer less than or equal to the number |
join | string, array[string] -> string | Returns array elements joined into a string with a separator |
keys | object -> array[string] | Returns an array of keys from an object |
length | array|object|string -> number | Returns the length of an array, object, or string |
map | expression, array -> array | Applies an expression to each element of an array |
max | array[number]|array[string] -> number|string | Returns the maximum value in an array |
max_by | array, expression -> any | Returns the element with maximum value by expression |
merge | object... -> object | Merges objects into a single object |
min | array[number]|array[string] -> number|string | Returns the minimum value in an array |
min_by | array, expression -> any | Returns the element with minimum value by expression |
not_null | any... -> any | Returns the first non-null argument |
reverse | array|string -> array|string | Reverses an array or string |
sort | array[number]|array[string] -> array | Sorts an array of numbers or strings |
sort_by | array, expression -> array | Sorts an array by expression result |
starts_with | string, string -> boolean | Returns true if the subject starts with the prefix |
sum | array[number] -> number | Returns the sum of an array of numbers |
to_array | any -> array | Converts a value to an array |
to_number | any -> number | Converts a value to a number |
to_string | any -> string | Converts a value to a string |
type | any -> string | Returns the type of a value as a string |
values | object -> array | Returns an array of values from an object |
| Function | Signature | Description |
abbreviate | string, number, string? -> string | Truncate string with ellipsis suffix |
camel_case | string -> string | Convert to camelCase |
capitalize | string -> string | Capitalize the first character |
center | string, number, string? -> string | Center-pad string to given width |
concat | string... -> string | Concatenate strings |
explode | string -> array | Convert a string to an array of Unicode codepoints |
find_first | string, string -> number | null | Find first occurrence of substring |
find_last | string, string -> number | null | Find last occurrence of substring |
indices | string, string -> array | Find all indices of substring occurrences |
implode | array -> string | Convert an array of Unicode codepoints to a string |
shell_escape | string -> string | Escape a string for safe use in shell commands (POSIX sh compatible, jq parity) |
inside | string, string -> boolean | Check if search string is contained in string |
is_blank | string -> boolean | Check if string is empty or whitespace-only |
kebab_case | string -> string | Convert to kebab-case |
lower | string -> string | Convert string to lowercase |
ltrimstr | string, string -> string | Remove prefix from string if present |
mask | string, number?, string? -> string | Mask string, keeping last N characters visible |
normalize_whitespace | string -> string | Collapse multiple whitespace to single space |
pad_left | string, number, string -> string | Pad string on the left to reach target length |
pad_right | string, number, string -> string | Pad string on the right to reach target length |
redact | string, string, string? -> string | Redact regex pattern matches with replacement |
repeat | string, number -> string | Repeat a string n times |
replace | string, string, string -> string | Replace occurrences of a substring. Use backtick-JSON syntax: replace(text, "\n", " ") |
reverse_string | string -> string | Reverse a string |
rtrimstr | string, string -> string | Remove suffix from string if present |
slice | string, number, number -> string | Extract substring by start and end index |
snake_case | string -> string | Convert to snake_case |
split | string, string -> array | Split string by delimiter. Use backtick-JSON syntax for literals: split(text, "\n") to split on newlines |
sprintf | string, any... -> string | Printf-style string formatting |
substr | string, number, number -> string | Extract substring by start index and length |
title | string -> string | Convert to title case |
trim | string -> string | Remove leading and trailing whitespace |
trim_left | string -> string | Remove leading whitespace |
trim_right | string -> string | Remove trailing whitespace |
upper | string -> string | Convert string to uppercase |
wrap | string, number -> string | Wrap text to specified width |
| Function | Signature | Description |
char_count | string -> number | Count characters in text |
char_frequencies | string -> object | Count character frequencies |
paragraph_count | string -> number | Count paragraphs in text |
reading_time | string -> string | Estimate reading time |
reading_time_seconds | string -> number | Estimate reading time in seconds |
sentence_count | string -> number | Count sentences in text |
word_count | string -> number | Count words in text |
word_frequencies | string -> object | Count word frequencies |
ngrams | string, number, string? -> array | Generate n-grams from text (word or character) |
bigrams | string -> array | Generate word bigrams (2-grams) |
trigrams | string -> array | Generate word trigrams (3-grams) |
tokens | string -> array | Simple word tokenization with normalization (lowercase, strip punctuation) |
tokenize | string, object? -> array | Configurable tokenization with options for case and punctuation handling |
stem | string, string? -> string | Stem a word using Snowball stemmer (Porter algorithm) |
stems | array, string? -> array | Stem an array of tokens |
stopwords | string? -> array | Get stopwords list for a language (default: English) |
remove_stopwords | array, string? -> array | Remove stopwords from token array |
is_stopword | string, string? -> boolean | Check if word is a stopword |
normalize_unicode | string, string? -> string | Unicode normalization (NFC, NFD, NFKC, NFKD) |
remove_accents | string -> string | Strip diacritics/accents from text |
collapse_whitespace | string -> string | Normalize whitespace (multiple spaces to single, trim) |
| Function | Signature | Description |
is_array | any -> boolean | Check if value is an array |
is_boolean | any -> boolean | Check if value is a boolean |
is_empty | any -> boolean | Check if value is empty |
is_null | any -> boolean | Check if value is null |
is_number | any -> boolean | Check if value is a number |
is_object | any -> boolean | Check if value is an object |
is_string | any -> boolean | Check if value is a string |
to_boolean | any -> boolean | Convert value to boolean |
type_of | any -> string | Get the type of a value |
auto_parse | any -> any | Intelligently parse strings to numbers, booleans, and nulls |
parse_booleans | any -> any | Recursively convert boolean strings to booleans |
parse_nulls | any -> any | Recursively convert null-like strings to null |
parse_numbers | any -> any | Recursively convert numeric strings to numbers |
| Function | Signature | Description |
url_decode | string -> string | URL decode a string |
url_encode | string -> string | URL encode a string |
url_parse | string -> object | Parse URL into components |
| Function | Signature | Description |
coalesce | any... -> any | Return first non-null value |
default | any, any -> any | Return default value if null |
if | boolean, any, any -> any | Conditional expression |
json_decode | string -> any | Parse JSON string |
json_encode | any -> string | Serialize value to JSON string |
json_pointer | any, string -> any | Access value using JSON Pointer (RFC 6901) |
now | -> number | Current Unix timestamp in seconds |
now_ms | -> number | Current Unix timestamp in milliseconds |
pretty | any, number? -> string | Pretty-print value as formatted JSON string |
env | -> object | Get all environment variables as an object |
get_env | string -> string | null | Get a single environment variable by name |
| Function | Signature | Description |
uuid | -> string | Generate a UUID v4 |
| Function | Signature | Description |
is_base64 | string -> boolean | Check if valid Base64 encoding |
is_credit_card | string -> boolean | Validate credit card number (Luhn check + length) |
is_email | string -> boolean | Validate email address format |
is_hex | string -> boolean | Check if valid hexadecimal string |
is_ipv4 | string -> boolean | Validate IPv4 address format |
is_ipv6 | string -> boolean | Validate IPv6 address format |
is_iso_date | string -> boolean | Validate ISO 8601 date format |
is_json | string -> boolean | Check if string is valid JSON |
is_jwt | string -> boolean | Check if valid JWT structure (3 base64url parts) |
is_phone | string -> boolean | Validate phone number format |
is_url | string -> boolean | Validate URL format |
is_uuid | string -> boolean | Validate UUID format |
luhn_check | string -> boolean | Generic Luhn algorithm check |
§Error Handling
Extension functions follow JMESPath conventions:
- Type errors return an error (e.g., passing a number to
upper)
- Invalid operations return null (e.g.,
index_at with out-of-bounds index)
use jmespath::{Runtime, Variable};
use jmespath_extensions::register_all;
let mut runtime = Runtime::new();
runtime.register_builtin_functions();
register_all(&mut runtime);
let expr = runtime.compile("upper(@)").unwrap();
let data = Variable::Number(serde_json::Number::from(42));
assert!(expr.search(&data).is_err());
let expr = runtime.compile("index_at(@, `10`)").unwrap();
let data = Variable::from_json("[1, 2, 3]").unwrap();
let result = expr.search(&data).unwrap();
assert!(result.is_null());