- Recap YAML vs JSON
- Learn JSONPath basics (root, dot notation, array indexing, slices)
- Work with dictionaries, lists, and nested structures
- Apply filters / criteria to select items
- Try practice exercises and review the quiz workflow

YAML vs JSON — quick recap
Both YAML and JSON represent structured data and are often interchangeable. Below is a compact comparison to help you choose the format and convert between them.
You can convert between YAML and JSON using online converters (e.g. json2yaml.com) or with small scripts in most languages.
Example JSON:
What is JSONPath?
JSONPath is a query language for JSON documents, analogous to how XPath works for XML or SQL for relational data. A JSONPath expression navigates the structure of a JSON document and returns matching nodes (typically as an array of matches). Use cases:- Extract properties from nested structures
- Select array elements by index, slice, or condition
- Support test/quiz platforms that validate JSONPath queries
Basic JSONPath concepts
$— the root of the JSON document.- Dot notation — access child properties:
$.car.color - Bracket notation — access arrays and special keys:
$['car'],$[0] - Array indices — single index (
$[0]), multiple indices ($[0,3]), slices ($[0:3]) - Filters — inside
?()to test elements:$[?(@.price > 1000)] @— the current element within a filter expression
JSONPath implementations vary slightly. Some engines always return results as arrays; others may return a single value. When practicing, expect results to be shown as an array of matches.
Quick examples
Given this JSON document:-
Get car details
Query:
Result:
-
Get the car’s color
Query:
Result:
-
Get the bus price
Query:
Result:
vehicles, then use $.vehicles.car.color.
Arrays (lists) and indexing
If the root is an array:$[0]— first element ("car")$[3]— fourth element ("bike")$[0,3]— first and fourth elements (["car","bike"])- Slices:
$[1:3]— elements at indices 1 and 2
Dictionaries and lists combined
Consider this car object with awheels array where each element is an object:
$.car.wheels— returns the fullwheelsarray (as a match):
-
Second wheel object (index 1)
Query:
Result:
-
Model of the second wheel
Query:
Result:
Filtering with criteria
Filters let you select array elements based on conditions instead of fixed indexes. Filters are written with?() and refer to the current element with @.
Numeric example:
Given the array:
- Select values greater than 40:
Query:
Result:
Support for operators like
in / nin, regex matching, or certain logical shortcuts varies by JSONPath engine. If in is not supported, combine comparisons with || (logical OR): (@ == 40 || @ == 43).Filtering objects by property
Using thewheels example, find the model where location equals rear-right:
Query:
model value(s) for wheel objects matching the filter.
Practice exercises
Try practical quiz exercises to reinforce what you’ve learned. The KodeKloud quiz interface shows:- Top-left: question panel
- Top-right: controls (Run / Show Solution)
- Lower-left: source data to query
- Lower-right: expected output
https://kodekloud.com/p/json-path-quiz

Links and references
- JSONPath project:
https://github.com/json-path/JsonPath - KodeKloud JSONPath quiz:
https://kodekloud.com/p/json-path-quiz - JSON ↔ YAML conversion tools (example):
https://json2yaml.com