my_data = %{"TopKey" => [
%{"StringKey" => "foo"},
%{"StringKey" => "bar"}
]
}
all = fn :get_and_update, data, next ->
Enum.map(data, next) |> :lists.unzip
end
IO.inspect get_and_update_in(my_data, ["TopKey", all, "StringKey"], &{&1, String.upcase &1})
{["foo", "bar"], %{"TopKey" => [%{"StringKey" => "FOO"}, %{"StringKey" => "BAR"}]}}
From Kernel.get_and_update_in/3
my_data = %{"TopKey" => [
%{"StringKey" => "foo"},
%{"StringKey" => "bar"}
]
}
IO.inspect (update_in my_data, ["TopKey", Access.all(), "StringKey"], &String.upcase/1)
%{"TopKey" => [%{"StringKey" => "FOO"}, %{"StringKey" => "BAR"}]}
From Access behaviour