meander

murtaza52 2024-05-30T13:07:43.550109Z

Hi, I am trying to parse a structure with arbitrary depth and branches, sample data -

{:role0 {:clients {:a 1
                   :b 2}
         :children {:role1 {:clients {:c 3}
                            :children {:role3 {:clients {:d 4}}}}
                    :role2 {:clients {:e 5
                                      :f 6}}}}}
to extract all the clients ->
[{:a 1} {:b 2} {:c 3} {:d 4} {:e 5} {:f 6}
Can I do it with meander ?

Pranav Ram 2024-05-30T16:34:53.328809Z

This isn't quite there but with a few tweaks should get you the output you want:

(->> (m/search data
        (m/$ {:clients (m/some ?clients)})
               ?clients)
     (into {}))

murtaza52 2024-05-31T19:27:52.688209Z

thanks @pranav.ram7