jmespath
JMESPath query language implementation for Python — query and transform JSON/dict structures with a declarative expression syntax. jmespath features: jmespath.search(expression, data) for querying nested dicts, field selection (a.b.c), array indexing (a[0]), slicing (a[0:3]), projections (a[*].b), filters (a[?x=='y']), multi-select list ([a, b, c]), multi-select hash ({key: a}), functions (length(), keys(), sort_by(), max_by()), pipe operator for chaining, and compiled expressions for repeated queries. Used extensively in AWS CLI/boto3 (--query parameter), AWS SDK internals, and Ansible. Standard JSON query language for agent data extraction from API responses.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Pure Python query evaluation — no code injection risk, no network calls. JMESPath expressions are data queries, not executable code. Safe to use with untrusted expression strings as no eval() is used internally.
⚡ Reliability
Best When
Extracting and transforming data from AWS API responses or complex nested JSON/dict structures — jmespath expressions are more readable than equivalent Python list comprehensions and identical to the AWS CLI --query syntax agents can reuse.
Avoid When
You need recursive descent (..) operators (use jsonpath-ng), need to mutate data, or work with non-dict data structures.
Use Cases
- • Agent AWS API data extraction — import jmespath; response = boto3.client('ec2').describe_instances(); instance_ids = jmespath.search('Reservations[*].Instances[*].InstanceId', response) — flatten nested AWS response to list of IDs; identical to AWS CLI --query parameter; agent AWS automation extracts specific fields from complex paginated responses
- • Agent JSON API filtering — data = requests.get(api_url).json(); active_users = jmespath.search('users[?status==`active`].{name: name, email: email}', data) — filter and reshape JSON response in one expression; agent processes API responses without Python list comprehensions for readable data extraction
- • Agent config query — expression = jmespath.compile('services[?type==`database`].connection_string'); conn_strings = expression.search(config) — precompile expression for repeated queries; agent applies same JMESPath expression to multiple API responses efficiently; compiled expressions 10x faster for repeated use
- • Agent data transformation — result = jmespath.search('sort_by(items, &price)[*].{name: name, price: price}', catalog) — sort by field and select specific keys in one expression; agent reformats API response for downstream processing without intermediate variables
- • Agent recursive search — values = jmespath.search('*.nested.value', deep_dict) — wildcard projections traverse all keys; agent extracts values from variable-depth response structures; works on any dict/list nesting level
Not For
- • JSONPath — jmespath and jsonpath are different standards; AWS uses jmespath; jmespath has no recursive descent operator (..); for recursive search use jsonpath-ng
- • Mutating data — jmespath is read-only query language; for modification use Python dict operations or jq
- • Non-JSON data — jmespath operates on Python dicts/lists; for querying XML use XPath with lxml
Interface
Authentication
No auth — local query library.
Pricing
jmespath is MIT licensed. Free for all use.
Agent Metadata
Known Gotchas
- ⚠ Returns None for missing paths (not KeyError) — jmespath.search('a.b.missing', data) returns None, not raises exception; agent code must check: result = jmespath.search(expr, data); if result is None: handle_missing() — never assume non-None return even for required fields
- ⚠ Backtick literals vs string comparisons differ — filter [?type=='string'] uses single quotes; [?count==`42`] uses backticks for numbers/booleans/null; agent code with filter expressions must use correct quoting; [?active==`true`] not [?active=='true'] for boolean match
- ⚠ Wildcard projections return None-filtered lists — a[*].b skips items where b is missing (returns None-filtered list not error); agent code counting results may get shorter list than input; all None values dropped by projection flattening
- ⚠ Pipe operator vs projection differ — a[*].b | [0] gets first of all b values; a[0].b gets b of first item; agent code building complex expressions must understand pipe chains the full left-side result before right-side processes
- ⚠ Compile expressions for repeated use — jmespath.search('a.b.c', data) recompiles expression every call; jmespath.compile('a.b.c') returns compiled expression reusable with compiled.search(data); agent loops processing 1000+ responses must precompile; 5-10x performance improvement
- ⚠ sort_by and max_by require field reference syntax — sort_by(items, &price) uses ampersand for field reference; agent code writing sort_by(items, 'price') fails with ParseError; & syntax is unique to jmespath and not obvious from JMESPath spec examples
Alternatives
Full Evaluation Report
Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for jmespath.
AI-powered analysis · PDF + markdown · Delivered within 30 minutes
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-06.