How can i find a specific data constellation in an array
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can i find a specific data constellation in an array
Hi,
i'm trying to verify a change of roles for a user in a report. The report is an array of [user,[roles]]. Which means every user is one entry in the array and next to the user information is an array of the roles of the user.
I know the username and the role that i added or removed. I can search the array for the username ($[*][?(@.name=='username')] which returns the complete user information without the roles. Similar i can search for the role and that returns the role information (several times) but without the user information.
Can i combine those two to find the one item that has the correct username and role? Or change the query so that it returns the roles as well? Or is there a way to identify the position of that user in the list and then query that specific entry in the array?
Thanks in advance
- Labels:
-
Assertions
-
Function Tests
-
REST
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you provide an example payload so people can see the structure/hierarchy please? This will help in answering your question.
Cheers,
Rich
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @richie
Here is an example of the structure (better formatted in the attachment)
[
{"user" : {
"id" : "1",
"name" : "user1"},
"roles" : [{
"id" : "a",
"roleName" : "role a"}
]
},
{"user" : {
"id" : "2",
"name" : "user2"},
"roles" : [{
"id" : "a",
"roleName" : "role a",},
{
"id" : "b",
"roleName" : "role b"}
]
}
]
