To query JSON with JMESPath in Python, first decode the JSON text into ordinary Python data, then evaluate a JMESPath expression against that data with jmespath.py. For example, people[0].name selects the first person’s name. JMESPath is for extracting and transforming JSON-shaped values; it does not replace JSON decoding.
How JMESPath fits into Python JSON parsing
JSON received from a file, HTTP response, or other source is text until a JSON parser decodes it. Python’s JSON decoder turns that text into Python dictionaries, lists, strings, numbers, booleans, and None. JMESPath then evaluates an expression against that in-memory structure and returns a selected or transformed value.
The Python implementation is jmespath.py. The official JMESPath Libraries page lists it as fully compliant with the language specification. The JMESPath Specification says that evaluating an expression against a JSON document produces a valid JSON result when evaluation completes without errors. In Python, the returned value is a Python representation of that result, not necessarily a JSON string.
The two operations are separate: json.loads() decodes JSON text, while jmespath.search() evaluates a query against the decoded value. If you already have a Python dictionary or list, pass it directly to JMESPath; do not encode and decode it again.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Run a minimal example
This example follows the full path from JSON text to a selected value:
import json
import jmespath
json_text = '{"people": [{"name": "Mina", "active": true}]}'
data = json.loads(json_text)
name = jmespath.search("people[0].name", data)
print(name) # Mina
The expression uses a field name, then a zero-based array index, then another field name. The result is the string "Mina", represented in Python as Mina. For an existing Python object, the query alone is enough:
data = {"people": [{"name": "Mina", "active": True}]}
name = jmespath.search("people[0].name", data)
Make sure the jmespath package is available in the Python environment running your program. This article does not specify a package version or Python compatibility range; check the package’s current metadata when those constraints matter to your project.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Build expressions from fields to collections
Begin with the smallest expression that answers the question, then add nesting or collection operations as needed. These examples use this input shape:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
data = {
"people": [
{"name": "Mina", "active": True, "score": 8},
{"name": "Omar", "active": False, "score": 5},
{"active": True, "score": 9}
]
}
Select a field, nested field, or array element
peoplereturns the people array.people[0]returns its first object. Array indexes start at zero.people[0].nameselects that object’s name.people[1].activereturns the second person’s active value.
Each dot follows a key in an object. An index selects a position in an array. If the input shape differs from what the expression expects, inspect the actual data and adjust the expression rather than assuming every record has every key.
Project values from an array
A projection applies a selection to each item in an array. For example, people[*].name asks for each person’s name. Projection behavior matters when some objects lack the projected key: missing projected values may be omitted from the resulting list. In the sample data, the third object has no name, so do not assume the result preserves a position for every input record. If alignment with original records matters, query the objects or their identifying fields in a way that preserves the distinctions your application needs, and verify the output with representative data.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Filter an array
A filter expression uses [? expression] to select array items that meet a condition. For example, people[?active == `true`] selects objects whose active value is true. JMESPath expressions use JSON-shaped values; the backtick notation here represents a JSON literal. Choose a comparison that matches the data type in the input. A string such as "true" is not the same value as the boolean true.
Return a smaller object with named fields
A multi-select hash lets a query construct an object with selected values under chosen names. For example, {first: people[0].name, is_active: people[0].active} returns a smaller object with the keys first and is_active. This is useful when downstream code needs a compact, named result rather than a single field or the whole source object.
Use functions when their input types match
JMESPath includes built-in functions, including type(@) for inspecting a value’s JSON type and to_number() for explicit conversion. Consult the function signatures for the exact accepted argument types and number of arguments. A function that expects an array of numbers cannot safely be applied to arbitrary strings or objects. Conversion is not a substitute for validating untrusted or inconsistent input.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Handle missing values and evaluation errors
A missing identifier does not always raise an exception. The specification says an unknown identifier evaluates to null; in Python, JSON null is represented as None. That means a None result can signal an absent field, but it can also be an intentional null in the data. If your application must tell those cases apart, check the input structure or query for enough context to make the distinction.
JMESPath defines evaluation error classes including invalid-type, invalid-value, unknown-function, and invalid-arity. A function can fail because its arguments have the wrong type, a value is invalid, a function name is not known, or the number of arguments is wrong. The specification requires implementations to indicate evaluation errors, but the precise way errors are signaled can depend on the implementation. Handle exceptions according to the behavior of the installed Python package rather than assuming every failure has the same form.
- Unexpected
None: Confirm the field exists in the decoded object and check whether the source contains JSONnull. Also review whether a projection omits missing values. - Function type error: Inspect the input value and compare its type with the function’s documented signature. Convert only when conversion is appropriate for the data.
- Unknown function or wrong argument count: Verify the function name and its required arity in the specification.
- Wrong shape or empty result: Print or inspect the decoded data first. Confirm that the expression is traversing an object or array of the shape you expect.
Debug queries without guessing
- Inspect the decoded value. Check the object keys, array contents, and Python types after JSON decoding. This separates malformed input or an unexpected shape from a query problem.
- Start with one step. Try a top-level key such as
people, then add a nested key or index. This identifies the point where the result diverges from expectation. - Check the result type and value. A query can return a string, number, boolean, list, object, or null-like value. Confirm that downstream code expects that shape.
- Test missing and mismatched cases. Include records with absent keys, explicit nulls, empty arrays, and values of unexpected types if those can occur in production.
- Look up exact syntax and function signatures. Use the official JMESPath Tutorial for expression patterns and the Specification for precise semantics and function behavior.
When JMESPath is a good fit
JMESPath is useful when a selection can be expressed declaratively: extract nested fields, project a value across records, filter a collection, or build a smaller object. The same expression can be kept separate from the surrounding Python control flow, which can make the intended selection easy to identify.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Ordinary Python traversal may be more straightforward when the task depends on application-specific branching, custom validation, or side effects. There is no performance comparison established here, so choose based on clarity and behavior rather than an assumed speed advantage. JMESPath has a formal specification and compliance suite, and the official project lists implementations in multiple languages; that can help when a query needs to be understood across environments, but individual data handling still needs tests.
Or skip the browser setup
If a website screenshot is one step in a larger workflow that later examines JSON or other extracted data, ScreenshotNeo is a separate way to capture the page without building browser automation first. It is a screenshot API and MCP server, not a JMESPath parser. The single-request example below saves a screenshot; see the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts and removes cookie or consent banners, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response indicates the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo free: 1,000 screenshots a month, no card required.
Free tools Windows power users keep installed
One-click scans. No signup required.
Official JMESPath references
For expression syntax and exact edge-case behavior, consult the JMESPath Tutorial, Specification, Libraries listing, Overview and Contents, and project home. The tutorial covers identifiers, nested access, indexes, projections, multi-selects, and functions; the specification is the reference for grammar, data types, and errors. The Python package’s current release and runtime compatibility should be checked in its package metadata when required, since those details are not stated here.
Frequently Asked Questions
Does JMESPath parse JSON text by itself?
No. Decode text first with Python’s JSON parser, then evaluate an expression on the resulting Python data.
Can I use the same JMESPath expression in another language?
JMESPath has a formal specification and implementations in multiple languages, but check the target implementation for its own error-signaling details.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

