JSONPath expression to find elements in array based on nested array values

Hi @maciej_itrun ,

Finally I found the solution after some trail and error. This should work for you as well.
Try this json path expression:

$.accountRequests[?(@.source.name == “IdentityNow” && @.provisioningTarget == “IdentityNow” && “assignedRoles” in @.attributeRequests…attributeName)]

For the nested array, we need to utilize the in expression to recursively search for attribute Name.

This will give the desired result of only the needed account request with assignedRoles attribute request in it. Here is the output I received when tried on https://www.javainuse.com/jsonpath

[
{
“accountId”: “xxxx”,
“provisioningResult”: “SUCCESS”,
“provisioningTarget”: “IdentityNow”,
“accountOperation”: “Modify”,
“source”: {
“name”: “IdentityNow”,
“id”: “xxxxxx”,
“type”: “SOURCE”
},
“attributeRequests”: [
{
“attributeValue”: “xxxxx”,
“attributeName”: “memberOf”,
“operation”: “Add”
},
{
“attributeValue”: “Test 1”,
“attributeName”: “assignedRoles”,
“operation”: “Add”
}
],
“ticketId”: “7263219262”
}
]

Regards,
Uday Kilambi