Courseiva
Transform data with filters and pluginsmediumMultiple ChoiceObjective-mapped

EX294 Transform data with filters and plugins Practice Question

A playbook uses the 'uri' module to query an API and registers the result. The API returns a JSON with a nested field 'data.users[0].name'. Which expression correctly extracts that name?

⚠ Common exam trap

Red Hat often tests the distinction between Jinja2 native dot notation (which requires the data to be in a parsed dictionary) and the `json_query` filter (which uses JMESPath syntax). Candidates may think that only single quotes are valid, but both quote styles work in Ansible.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

{{ result | json_query("data.users[0].name") }}

Options B and D are both correct because the `json_query` filter accepts JMESPath queries quoted with either single or double quotes. Both `'data.users[0].name'` and `"data.users[0].name"` are syntactically valid in Ansible Jinja2 expressions. The `uri` module parses JSON response into a dictionary, so `result` is the top-level object, and the JMESPath query correctly extracts the nested field. Option C is incorrect because it uses native Jinja2 dot notation, which would only work if `result` were already a deeply nested dictionary, but the registered object may still contain headers and other HTTP metadata. Option A is incorrect because JMESPath uses zero-based index without the dot notation, i.e., `users[0]`, not `users.0`.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • {{ result | json_query('data.users.0.name') }}

    Why it's wrong here

    Incorrect. Uses `users.0`, which is not valid JMESPath. JMESPath uses bracket notation for indices like `users[0]`.

  • {{ result | json_query("data.users[0].name") }}

    Why this is correct

    Correct. The query `"data.users[0].name"` uses valid JMESPath syntax with double quotes around the query string.

  • {{ result.data.users[0].name }}

    Why it's wrong here

    Incorrect. Native Jinja2 dot notation would work only if `result` were a parsed dictionary of the response body, but the registered variable includes the entire HTTP response object, so `result.data` may not directly access the parsed JSON.

  • {{ result | json_query('data.users[0].name') }}

    Why this is correct

    Correct. The query `'data.users[0].name'` uses valid JMESPath syntax with single quotes around the query string.

About these practice questions

Courseiva writes every EX294 question from scratch — 520 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This EX294 practice question is part of Courseiva's free Red Hat certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the EX294 exam.