Get value from nested list of map with string and atom keys

I have this list of maps:

 [
%{
"$value" => %{"$sum": %{"id" => 2}},

 },
%{
"$value" => %{"$sum": %{"id" => 1}},
}
]

I need to get the id value. The problem is with the $sum key, which is an atom.

How I can I fetch it for both of the above maps.
Thanks.

Something like:

Enum.map(list, fn m -> get_in(m, [“value”, :”$sum”, “id”]) end)

Might do the trick. Note how to address an atom that has non alpha characters in its name.

3 Likes