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

**URL:** <https://developer.sailpoint.com/discuss/t/jsonpath-expression-to-find-elements-in-array-based-on-nested-array-values/35291>\
**Category:** SHF Discussion and Questions\
**Tags:** workflows\
**Created:** [March 14, 2024, 12:38pm UTC](https://developer.sailpoint.com/discuss/t/jsonpath-expression-to-find-elements-in-array-based-on-nested-array-values/35291 "2024-03-14T12:38:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![uday\_kilambi](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/uday_kilambi/32/31482_2.png) [@uday\_kilambi](https://developer.sailpoint.com/discuss/u/uday_kilambi)\
**Post date:** [March 14, 2024, 4:08pm UTC](https://developer.sailpoint.com/discuss/t/jsonpath-expression-to-find-elements-in-array-based-on-nested-array-values/35291/6 "2024-03-14T16:08:18Z")

</div>

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](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

---

_[View the full topic](https://developer.sailpoint.com/discuss/t/jsonpath-expression-to-find-elements-in-array-based-on-nested-array-values/35291)._
