Courseiva

EX294 Transform data with filters and plugins Practice Question

A playbook registers the output of a shell command that returns a JSON string. You need to parse this JSON string into a usable dictionary within the same play. Which filter should you apply to the registered variable?

⚠ Common exam trap

A common mix-up: candidates confuse `from_json` with `to_json`; the former parses a string into data, while the latter serializes data into a string.

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

✓

from_json

When a command returns JSON as a string, the registered variable stores that string, not a parsed object. The `from_json` filter is specifically designed to deserialize JSON strings into Ansible data structures, enabling direct access to nested keys. Using the wrong direction or a query filter would not achieve the required parsing.

Answer analysis

Option-by-option breakdown

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

  • ✗

    json_query

    Why it's wrong here

    The `json_query` filter applies a JMESPath expression to an existing data structure; it does not parse a JSON string into a data structure. It expects the input to already be a dictionary or list. Using it on a raw string would fail or produce unexpected results.

  • ✗

    from_yaml

    Why it's wrong here

    The `from_yaml` filter parses YAML-formatted strings. While JSON is a subset of YAML and some JSON strings might parse successfully, this filter is semantically intended for YAML and may not handle all JSON edge cases identically. The dedicated `from_json` filter is the correct choice for JSON input.

  • ✗

    to_json

    Why it's wrong here

    The `to_json` filter performs the opposite operation: it serializes a data structure into a JSON string. Applying it to a string that is already JSON would double-encode it, producing a quoted string rather than a dictionary, and would not allow direct access to the parsed fields.

  • ✓

    from_json

    Why this is correct

    The `from_json` filter parses a JSON-formatted string and returns the corresponding Python data structure, such as a dictionary or list. This is exactly what is needed to convert the registered stdout string into an accessible dictionary for subsequent tasks.

About these practice questions

This EX294 question is part of Courseiva's 392-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Red Hat exam blueprint

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.