Student question: Json path

raghu:
@KK @Rahul Soni in this practice lab question,
Use JSON PATH query to retrieve the osImages of all the nodes and store it in a file /opt/outputs/nodes_os.txt

is there an easy way to find the details given in the hint provided in the second line in the practice test (i.e., The osImages are under the nodeInfo section under status of each node.)?

I felt it bit time consuming thing to find the exact path/indentation of the object asked with a temp file.(I created a temporary output file in json format with “k get nodes -o json > /tmp/tmp.txt”). Once the path is identified the jsonpath query formation is fine.

Rahul Soni:
afaik you have to use json path

raghu:
I am using the jsonpath only. but to find what’s the path of the object is a tedious jobs. How do you find an object path so fast. I tried it by using the temp file created by the output of the kubectl command’s json path & then manually find it.

my ask is Do you know any shortcut or easy way to get it?

raghu:
@Rahul Soni Could u pls provide ur valuable comments.

Rahul Soni:
@raghu have you checked the mumshad’s “free” course on json path on kodekloud?

raghu:
I have gone through that following all lectures.
my simple ask is that in the long json output, is there an easy way to get the path of the object?
like when we run “k get nodes” it will give a huge json path. (how to easily get the status.containerStatuses[*].restartCount) from it? is it purely on the basis of memorization through practice? because manual extraction is very fuzzy.

Rahul Soni:
afaik, yes you have to. but as you practice you can memorize the parent and its child key value.

raghu:
okay. Thanks @Rahul Soni for your patience in answering my query. I appreciate it. :+1: