Json path extract based on multiple condition which include condition on child as well not working

531 Views Asked by At

I want to extract id where

holder.parameter="jira-software-users" and "permission"="ADMINISTER_PROJECTS"

I am using $.permissions[?(@.holder.parameter=="jira-software-users")]).id or $.permissions[?(@.permission=="ADMINISTER_PROJECTS")].id or by combining them

it is not working correctly. how can achieve the same? I am testing this at https://jsonpath.com/

   {
    "permissions": [
        {
            "id": 10025,
            "self": "http://localhost:2990/jira/rest/api/2/permissionscheme/0/permission/10025",
            "holder": {
                "type": "projectRole",
                "parameter": "10002",
                "expand": "projectRole"
            },
            "permission": "MANAGE_WATCHERS"
        },
        {
            "id": 10004,
            "self": "http://localhost:2990/jira/rest/api/2/permissionscheme/0/permission/10004",
            "holder": {
                "type": "projectRole",
                "parameter": "10002",
                "expand": "projectRole"
            },
            "permission": "ADMINISTER_PROJECTS"
        },
        {
            "id": 10401,
            "self": "http://localhost:2990/jira/rest/api/2/permissionscheme/0/permission/10401",
            "holder": {
                "type": "projectRole",
                "parameter": "jira-software-users",
                "expand": "projectRole"
            },
            "permission": "MANAGE_SPRINTS_PERMISSION"
        },
        {
            "id": 10740,
            "self": "http://localhost:2990/jira/rest/api/2/permissionscheme/0/permission/10740",
            "holder": {
                "type": "group",
                "parameter": "jira-software-users",
                "expand": "group"
            },
            "permission": "ADMINISTER_PROJECTS"
        }
    ],
    "expand": "user,group,projectRole,field,all"
}
1

There are 1 best solutions below

0
On

I got it using

$.permissions..[?(@.permission=="ADMINISTER_PROJECTS" &&  @.holder.parameter=="jira-software-users")].id