Skip to main content
Welcome — in this concise JSONPath tutorial you’ll learn how to query JSON data that contains objects (dictionaries), arrays (lists), and nested combinations of both. We’ll also cover simple criteria/filters, and how to practice with hands-on exercises. This lesson is designed for beginners: we start with a quick comparison of YAML vs JSON, then step through JSONPath basics (dot notation, array indexing), combining objects and arrays, and filtering. Finally, you’ll find pointers to practice quizzes and reference materials.
A presentation slide titled "Objectives" with bulleted topics about YAML, YAML vs JSON, JSONPath (dictionaries, lists, lists and dictionaries, criteria) and practice exercises. There's also a small screenshot of a JSONPath tool on the right.
Callouts and quick tips
JSONPath is often described as “SQL for JSON”. Many interactive JSONPath tools display results inside an array even when a single value is returned — keep that in mind when matching expected outputs in exercises.
What is YAML vs JSON?
  • Both formats represent structured data and are widely used for configuration, APIs, and data interchange.
  • YAML uses indentation and dashes for readability; JSON uses curly braces ({}) and square brackets ([]) and is slightly more verbose.
  • Most languages and tools provide easy conversion between YAML and JSON (online converters or libraries).
Comparison summary: Example JSON (we’ll use JSON for the rest of the lesson):
Equivalent YAML:
What is JSONPath?
  • JSONPath is a query language for JSON data, similar in purpose to SQL for relational tables.
  • A JSONPath expression selects a subset of a JSON document (values, objects, or arrays).
  • The JSONPath root is denoted with $.
Basic object/dot notation
  • Use dot notation to traverse objects/dictionaries.
  • $ represents the root of the JSON document.
Given this JSON:
Examples: Query:
Result (many tools return results inside an array):
Query:
Result:
To access specific properties: Query:
Result:
Query:
Result:
If the document has a nested parent object:
Query:
Result:
Query:
Result:
Arrays (lists) and index access
  • Use square-bracket indexing for arrays.
  • Indexes start at 0.
Given this array as the root:
Examples: Query:
Result:
Query:
Result:
Select multiple indices: Query:
Result:
Combining objects and arrays Using the car-with-wheels JSON example:
Get all wheels: Query:
Result:
Get the second wheel (index 1): Query:
Result:
Get the model of the second wheel: Query:
Result:
Filtering with criteria
  • Use filters to select array elements that meet expressions.
  • Filters use the syntax [?(<expression>)].
  • Inside a filter, @ refers to the current array element.
Example: select numbers greater than 40. Given:
Query:
Result:
Common filter operators:
Filter operator availability (like in / not in) varies between JSONPath implementations. If a filter doesn’t work in your tool, check that implementation’s documentation.
Filtering objects by property Rather than rely on array order, filter by object properties. For example, find the model where location equals rear-right. Given:
Query:
Result:
Quick reference: common JSONPath expressions Practice exercises and quiz interface
  • The practice quiz shows the source JSON on the left and the expected output on the right.
  • Type a JSONPath expression in the answer area; your query is applied automatically and the result updates instantly.
  • When your query produces the expected output, the question is marked complete.
  • If you get stuck, use the “Show Solution” button to reveal the correct JSONPath.
Practice portal:
Further reading and references
  • Official JSONPath repository and docs: https://github.com/json-path/JsonPath
  • JSON vs YAML background: https://www.jsontoyaml.com/
  • JSONPath implementations and language-specific libraries can be found via the repository above.
If you’d like advanced JSONPath patterns, recursive descent, or tooling-specific examples covered in a follow-up lesson, leave feedback and we can expand this guide.

Watch Video

Practice Lab