JSONPath Support
VipinVKKariyad opened this issue · comments
we need to get exact path of a sub object so need to add this command in documentation or need a method for json path
kubectl get nodes -o=json | jq -r '
def traverse(level):
. as $in
| if type == "object" then
to_entries | map(
"##" + (level | tostring) + " " + .key + ": " + (
if .value | type == "object" or type == "array" then
"\n" + (.value | traverse(level + 1))
else
.value | tostring
end
)
) | .[]
elif type == "array" then
map("##" + (level | tostring) + " " + (. | tostring) + (
if type == "object" or type == "array" then
"\n" + (. | traverse(level + 1))
else
""
end
)) | .[]
else
"##" + (level | tostring) + " " + (. | tostring)
end;
.items[] | traverse(1)'
op will be
This issue is currently awaiting triage.
SIG Docs takes a lead on issue triage for this website, but any Kubernetes member can accept issues by applying the triage/accepted
label.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
Hi @VipinVKKariyad Could you please provide the URL of the page in the issue where you are suggesting an improvement?
/triage needs-information
we need to get exact path of a sub object so need to add this command in documentation or need a method for json path
kubectl get nodes -o=json | jq -r ' def traverse(level): . as $in | if type == "object" then to_entries | map( "##" + (level | tostring) + " " + .key + ": " + ( if .value | type == "object" or type == "array" then "\n" + (.value | traverse(level + 1)) else .value | tostring end ) ) | .[] elif type == "array" then map("##" + (level | tostring) + " " + (. | tostring) + ( if type == "object" or type == "array" then "\n" + (. | traverse(level + 1)) else "" end )) | .[] else "##" + (level | tostring) + " " + (. | tostring) end; .items[] | traverse(1)'
op will be
I do not understand the link mentioned in ##1, ##2, ##3 seems like mistakenly added. However the code stated just convert the json data in different format and content remains the same. If you are trying to find subobject or subresource the client-go can help.