5.6k views
1 vote
List all the pods showing name and namespace with a json path expression.

A) $..metadata.name, $..metadata.namespace

B) $.items[*].metadata.name, $.items[*].metadata.namespace

C) $..name, $..namespace

D) $.pods[*].name, $.pods[*].namespace

1 Answer

4 votes

Final answer:

The correct option for listing all the pods' name and namespace with a JSON path expression is B) $.items[*].metadata.name, $.items[*].metadata.namespace.

Step-by-step explanation:

The correct option for listing all the pods' name and namespace with a JSON path expression is B) $.items[*].metadata.name, $.items[*].metadata.namespace.

This JSON path expression selects the name and namespace values from the metadata of each item in the items array.

For example, if we have a JSON object with multiple pods, this expression will retrieve the name and namespace of each pod in the namespace.

User Dao Lam
by
8.4k points