Robot Framework JMESPath Library
A Robot Framework library providing high-performance JSON querying using JMESPath expressions.
Why JMESPath?
JMESPath offers significant advantages over JSONPath for Robot Framework testing:
- Better Performance: Native Python implementation with superior performance
- More Powerful: Rich filtering, projections, and transformations
- Better Maintained: Active development and strong community support
- Simpler Syntax: Cleaner, more intuitive query expressions
- Standardized: Well-defined specification and behavior
Installation
pip install robotframework-jmespath
Quick Start
*** Settings ***
Library JMESPathLibrary
*** Test Cases ***
Query JSON Data
${json}= Evaluate {"users": [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]}
${name}= JSON Search String ${json} users[0].name
Should Be Equal ${name} Alice
${names}= JSON Search List ${json} users[*].name
Should Contain ${names} Alice
Should Contain ${names} Bob
Keywords
JSON Search String
Execute a JMESPath query and return a single string result.
Arguments:
data: JSON data to query (dict, list, or JSON string)expression: JMESPath expression
Returns: String value (first result if multiple matches), or empty string if no match
Examples:
${tenant}= JSON Search String ${response} imdata[0].fvTenant.attributes.name
${ip}= JSON Search String ${response} imdata[0].fvBD.children[?fvSubnet] | [0].fvSubnet.attributes.ip
JSON Search List
Execute a JMESPath query and return results as a list.
Arguments:
data: JSON data to query (dict, list, or JSON string)expression: JMESPath expression
Returns: List of results, or empty list if no matches
Examples:
${names}= JSON Search List ${response} imdata[0].fvTenant.children[*].fvAp.attributes.name
${ips}= JSON Search List ${response} imdata[0].fvBD.children[*].fvSubnet.attributes.ip
JMESPath Syntax Overview
Basic Operations
| Operation | Example | Description |
|---|---|---|
| Object access | foo.bar |
Access nested object |
| Array access | foo[0] |
Access array element |
| Array slice | foo[0:2] |
Slice array |
| Wildcard | foo[*].bar |
All array elements |
| Filter | foo[?bar=='value'] |
Filter array |
| Pipe | foo | [0] |
Chain expressions |
Common Patterns
Access nested object:
imdata[0].fvTenant.attributes.name
Filter array by attribute:
imdata[0].fvTenant.children[?fvAp.attributes.name=='AP1'] | [0]
Get all names from array:
imdata[0].fvTenant.children[*].fvAp.attributes.name
Filter with multiple conditions:
users[?age > `25` && active == `true`]
Comparison with JSONPath
| Feature | JSONPath | JMESPath |
|---|---|---|
| Root | $ |
(implicit) |
| Child access | $.foo.bar |
foo.bar |
| Recursive descent | $..field |
Not supported* |
| Array filter | $[?(@.age > 25)] |
[?age > \25`]` |
| Wildcard | $.* |
* or [*] |
| Pipe/Chain | Not supported | foo | [0] |
*For recursive descent, use explicit paths: children[?fvAp]
Usage with REST API Testing
Example: Cisco ACI API Testing
*** Settings ***
Library RequestsLibrary
Library JMESPathLibrary
*** Test Cases ***
Verify Tenant Configuration
# Make API call
${response}= GET On Session apic /api/mo/uni/tn-TENANT1.json params=rsp-subtree=full
${json}= Set Variable ${response.json()}
# Query with JMESPath
${tenant_name}= JSON Search String ${json} imdata[0].fvTenant.attributes.name
Should Be Equal ${tenant_name} TENANT1
# Query nested objects
${ap_name}= JSON Search String ${json}
... imdata[0].fvTenant.children[?fvAp.attributes.name=='AP1'] | [0].fvAp.attributes.name
Should Be Equal ${ap_name} AP1
# Get all subnet IPs
${subnets}= JSON Search List ${json}
... imdata[0].fvTenant.children[*].fvBD.children[*].fvSubnet.attributes.ip
Should Contain ${subnets} 10.0.0.1/24
Development
Setup Development Environment
# Clone repository
git clone https://github.com/netascode/robotframework-jmespath.git
cd robotframework-jmespath
# Install in development mode
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
Running Tests
# Run all tests (unit tests + robot tests via pytest wrapper)
pytest tests/
# Run unit tests only
pytest tests/test_unit.py
# Run robot acceptance tests directly
robot tests/acceptance.robot
# Run acceptance tests via pytest wrapper
pytest tests/test_acceptance.py
# Run with coverage
pytest --cov=JMESPathLibrary tests/
# Run linters
ruff check .
mypy .
bandit -r JMESPathLibrary/
Code Quality
This project uses:
- ruff for linting and formatting
- mypy for type checking
- bandit for security analysis
- pytest for testing
- pre-commit for git hooks
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run the test suite
- Submit a pull request
Resources
License
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.
Authors
- Oliver Boehmer (@oboehmer)
Acknowledgments
- Inspired by the need for high-performance JSON querying in network automation testing
- Built on the excellent jmespath.py library
- Part of the Network-as-Code ecosystem
Metadata
Release files for robotframework-jmespath 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| robotframework_jmespath-0.1.0.tar.gz | 49.5 kB | Without provenance | Details for robotframework_jmespath-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| robotframework_jmespath-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for robotframework_jmespath-0.1.0-py3-none-any.whl |
Total release size: 62.4 kB
Release files / robotframework_jmespath-0.1.0.tar.gz
| Download URL | robotframework_jmespath-0.1.0.tar.gz |
|---|---|
| Size | 49.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cccb14298ce291d4f8d88b0fb1b9f7e2780cb17cb025b6c48f2b4e7b92ba42b1
|
|
BLAKE2b-256 checksum How to use checksums |
9facb0e121c19583af62e03766ff57c3e43ab3f13130370bbb585d45ec45fa54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.7
|
Release files / robotframework_jmespath-0.1.0-py3-none-any.whl
| Download URL | robotframework_jmespath-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5acc4bb2c1d31a90962176492ccc4b675a1ce8f89275d1fada02490ed4471813
|
|
BLAKE2b-256 checksum How to use checksums |
c54bd64f0bcb7362493fda70c6ae2422643f8fb0439d42a45a15831e61218b0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.7
|
Security for robotframework-jmespath 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.