How get object in script in aggregations

I have this object which have ArrayList wirh objects

"sizeData" : {
           "id" : 1,
           "elasticSizeScale" : {
             "id" : 3,
             "sizes" : [
               {
                 "id" : 321,
                 "sizeOrder" : 2
               },
               {
                 "id" : 323,
                 "sizeOrder" : 4
               },
               {
                 "id" : 322,
                 "sizeOrder" : 3
               }
             ]
           }
         }

How do i get the object in List? How to use foreach to retrieve an object from a list?
I need " "id" : 321, "sizeOrder" : 2""

If you want to get object 1, I guess you can do something like:

sizes[0]

Not sure if this is what you are looking for though. What is the use case here?

Not really. I use 'for' to go through all objects from the list

for(int i=0; i<doc['sizeData.elasticSizeScale.sizes.id'].length; i++){
  doc['sizeData.elasticSizeScale.sizes.id'][i];
}

but i can get only one field, not all object. I need get all object

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.