Search in array object


Is there a solution to search in an array object ?

Looping on each of the objects and recursively in the objects / array included works but take some time … I was wondering if there was any faster.


Christophe SACHOT

if you are using v16R6/v17, you would want to use a collection instead of an object array.

Hi Keisuke,

We are currently in 4Dv16.3 but I will test your solution on v17.

Thank you for your quick reply.

I tested the function collection.query but it seem do not work if the collection contain another collection.

That work only for the first level of collection, i’m right ?

Thanks for your answer.

you can use dot notation in the query path if the collection has sub objects.

if you need to handle different objects with different structures differently,

it might make more sense to use map() filter() or reduce().

map: when the number of elements don’t change, but their contents do.

filter: when the number of elements change but their contents don’t.

reduce: when the number of elements change and also their contents.