Check if field exists in any map value

60 views Asked by At

I have the following structure:

   "my-map": {
      "my-key1": {
         "field-to-find": {}
      },
      "my-key2": {
         "field-to-find": {}
      },
      "my-key3": {}
   }

I want to check if field-to-find exists in any of the values of my-map. Is this possible?

Things I tried:

  1. Using my-map.exists(i, has(i.field-to-find)) -> doesn't work because i returns just the key, not the value of the map
  2. Using my-map.exists(i, has(my-map.i.field-to-find)) -> doesn't work because i is treated as a string, is there a way to reference it as a variable?
1

There are 1 answers

0
helpmeplease On

I figured out mymap.exists(v, has(mymap[v].fieldtofind)) works.