Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONPath Support #46848

Closed
VipinVKKariyad opened this issue Jun 17, 2024 · 6 comments
Closed

JSONPath Support #46848

VipinVKKariyad opened this issue Jun 17, 2024 · 6 comments
Labels
needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@VipinVKKariyad
Copy link

VipinVKKariyad commented Jun 17, 2024

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

##1 status:
##2 nodeInfo:
##3 osImage: Ubuntu 20.04.5 LTS

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jun 17, 2024
@k8s-ci-robot
Copy link
Contributor

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.

@dipesh-rawat
Copy link
Member

Hi @VipinVKKariyad Could you please provide the URL of the page in the issue where you are suggesting an improvement?

/triage needs-information

@k8s-ci-robot k8s-ci-robot added the triage/needs-information Indicates an issue needs more information in order to work on it. label Jun 17, 2024
@Ritikaa96
Copy link
Contributor

Ritikaa96 commented Jun 20, 2024

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

##1 status: ##2 nodeInfo: ##3 osImage: Ubuntu 20.04.5 LTS

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.

@T-Lakshmi
Copy link
Contributor

@VipinVKKariyad,
Are you still facing this issue? if yes, please provide above requested details which are necessary to help you in resolving.
Please close the issue if it already resolved.

@T-Lakshmi
Copy link
Contributor

Hello @VipinVKKariyad,

As we not hear from you since long, iam closing this issue. Feel free to reopen if you are still observing this issue and provide requested details.

/close

@k8s-ci-robot
Copy link
Contributor

@T-Lakshmi: Closing this issue.

In response to this:

Hello @VipinVKKariyad,

As we not hear from you since long, iam closing this issue. Feel free to reopen if you are still observing this issue and provide requested details.

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

5 participants