Hi there, I’m trying to find an effective way to find if an id is returned in an array of objects.
My JSON response is below. I’m trying to write a test that would be true if one of the objects has a venueId of 8b0c9a4c-3ec9-4cf5-bb9c-ce7441ec895d
Any help on this would be great. I’m trying to avoid looping through the array, as it won’t be efficient later when the array gets larger.
{
"items": [
{
"createdAt": "2020-12-10T15:27:27.660Z",
"name": "my studio",
"userId": "auth0|5fd0c3ffe3b04b0076a17769",
"venueId": "0693ca98-82cb-41c2-9db7-12750066edb8"
},
{
"createdAt": "2020-12-10T15:26:58.987Z",
"name": "my studio",
"userId": "auth0|5fd0c3ffe3b04b0076a17769",
"venueId": "3f8ddde1-fc61-4b00-b608-86a67ff52e9a"
},
{
"createdAt": "2020-12-10T15:28:05.984Z",
"name": "my studio",
"userId": "auth0|5fd0c3ffe3b04b0076a17769",
"venueId": "46ac6b2c-64d4-4b90-ac1a-bc626b0c962c"
},
{
"createdAt": "2020-12-10T15:36:05.076Z",
"name": "my studio",
"userId": "auth0|5fd0c3ffe3b04b0076a17769",
"venueId": "8b0c9a4c-3ec9-4cf5-bb9c-ce7441ec895d"
},
{
"createdAt": "2020-12-10T15:30:45.372Z",
"name": "my studio",
"userId": "auth0|5fd0c3ffe3b04b0076a17769",
"venueId": "94376601-ed78-4355-a294-034109a5a62a"
},
{
"createdAt": "2020-12-10T15:25:45.353Z",
"name": "my studio",
"userId": "auth0|5fd0c3ffe3b04b0076a17769",
"venueId": "aaa3e4cb-9891-42c9-a2a5-cbfa8392d2bc"
},
{
"createdAt": "2020-12-10T15:25:16.106Z",
"name": "my studio",
"userId": "auth0|5fd0c3ffe3b04b0076a17769",
"venueId": "ddb6d540-79f3-483b-bf44-6df8d715ee23"
}
]
}