mediumMultiple ChoiceObjective-mapped
XK0-006 Practice Question: A script receives a JSON object where keys are…
A script receives a JSON object where keys are user IDs. Which command extracts the 'status' of user id '123'?
⚠ Common exam trap
Watch out — candidates often default to using `select(.id=="123")` as if the JSON were an array of objects with an 'id' field, failing to recognize that the user IDs are the object keys themselves, requiring direct key access with `.["123"]`.
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
✓
echo "$json" | jq '.["123"].status'
The JSON object uses user IDs as keys, so `.["123"]` directly accesses the object property for user ID '123', and `.status` extracts the 'status' field from that nested object. The `jq` syntax `.["key"]` is the standard way to access a property by a string key in a JSON object.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
echo "$json" | jq '.status'
Why it's wrong here
Attempts to access .status at the root, not within a specific key.
- ✗
echo "$json" | jq '. | select(.id=="123") | .status'
Why it's wrong here
Assumes an array of objects with .id, not a key-based object.
- ✗
echo "$json" | jq '.[] | select(.id=="123") | .status'
Why it's wrong here
Iterates over array elements, not applicable for an object with keys.
- ✓
echo "$json" | jq '.["123"].status'
Why this is correct
Correctly accesses the object by key and extracts status.
Go deeper
Related to this question
About these practice questions
This XK0-006 question is part of Courseiva's 979-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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This XK0-006 practice question is part of Courseiva's free CompTIA 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 XK0-006 exam.