nerdexam
Check_Point

156-521 · Question #156

156-521 Question #156: Real Exam Question with Answer & Explanation

The correct answer is B. jq '.objects[] | {name, uid}'. Using jq '.objects[] | {name, uid}' extracts a new object with only the desired fields (name, uid) from each item in the array. This is ideal for clean output in scripts.

Question

You need to extract multiple fields (name and uid) from each object in the JSON array. Which command is correct?

Options

  • Ajq '.objects[].name, .uid'
  • Bjq '.objects[] | {name, uid}'
  • Cjq '.objects | name, uid'
  • Djq 'name and uid from .objects[]'

Explanation

Using jq '.objects[] | {name, uid}' extracts a new object with only the desired fields (name, uid) from each item in the array. This is ideal for clean output in scripts.

Community Discussion

No community discussion yet for this question.

Full 156-521 Practice