JSONPath Wildcard Operator (*)
Use the JSONPath wildcard * to select all elements or properties at a given level. Learn syntax, examples, and common use cases for the wildcard operator.
Detailed Explanation
The Wildcard Operator in JSONPath
The asterisk * is a wildcard that matches all members of an object or all elements of an array at the current level. It is one of the most powerful operators for exploring JSON structures.
Syntax
$.store.* // all direct children of store
$.store.books[*] // all elements in the books array
With Objects
Given:
{
"store": {
"name": "TechBooks",
"location": "Online",
"rating": 4.8
}
}
$.store.* returns ["TechBooks", "Online", 4.8] — all property values regardless of their names.
With Arrays
Given:
{
"colors": ["red", "green", "blue"]
}
$.colors[*] returns ["red", "green", "blue"] — every element in the array.
Nested Wildcard
You can chain wildcards to access properties across multiple levels:
$.users[*].name // name of every user
$.data[*].tags[*] // every tag across all data entries
Wildcard vs. Recursive Descent
| Operator | Symbol | Scope |
|---|---|---|
| Wildcard | * |
Current level only |
| Recursive descent | .. |
All levels (deep) |
The wildcard operates at a single depth level, so $.store.* only returns direct children of store, not nested grandchildren. Use recursive descent (..) when you need to search through the entire tree.
Performance Note
Wildcards on large arrays are efficient because the evaluator simply iterates over the current level. However, combining wildcards with filters on huge datasets may increase processing time.
Use Case
Use the wildcard operator when you need to extract all values from an object without knowing the property names, or when iterating over every element of an array such as listing all items in a shopping cart or all records from a paginated API response.