EX294 Transform data with filters and plugins Practice Question
A task registers the output of a command that returns a string containing a JSON document in `result.stdout`. You must extract the numeric value at `metrics.cpu.load` and use it as an integer in a subsequent comparison. Which expression correctly parses the string and retrieves the integer value?
⚠ Common exam trap
The trap here is assuming `to_json` and `from_json` are interchangeable, when only `from_json` parses a string into structured data.
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.stdout | from_json | json_query('metrics.cpu.load') | int }}
The correct order is to parse the raw JSON string first with `from_json`, then traverse the nested structure with `json_query`, and finally cast the extracted value with `int`. Reversing or substituting `to_json` breaks the pipeline because it serializes rather than parses. Using `map` is inappropriate for a single dictionary input, and querying before parsing cannot succeed on a raw string.
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.stdout | from_json | json_query('metrics.cpu.load') | int }}
Why this is correct
`from_json` parses the JSON string into a Python dictionary, `json_query` traverses the nested path `metrics.cpu.load`, and `int` coerces the resulting value to an integer for comparison. This chain matches the scenario where stdout is a JSON string and the target is a nested numeric field.
- ✗
{{ result.stdout | json_query('metrics.cpu.load') | from_json | int }}
Why it's wrong here
`json_query` requires structured input, but `result.stdout` is a raw string at this point. Applying `json_query` before parsing fails or returns nothing. Additionally, placing `from_json` after `json_query` is backwards: the value at that path is already a number, so parsing it as JSON is unnecessary and incorrect.
- ✗
{{ result.stdout | to_json | json_query('metrics.cpu.load') | int }}
Why it's wrong here
`to_json` serializes an object into a JSON string; it does not parse a JSON string into structured data. Applying `to_json` to a string produces a quoted JSON string, and `json_query` then cannot traverse into a dictionary because no dictionary exists. The pipeline fails to extract the numeric field.
- ✗
{{ result.stdout | from_json | map(attribute='metrics.cpu.load') | int }}
Why it's wrong here
`map(attribute='metrics.cpu.load')` expects a list of items and extracts an attribute from each. After `from_json`, the data is a single dictionary, not a list, so `map` does not iterate correctly. Dotted attribute lookup is also not how `map` handles nested paths, making this expression invalid for the scenario.
Go deeper
Related to this question
About these practice questions
One of 392 original EX294 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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.