I would do it something like this:
def transform([{_, _}|_] = list) do
Enum.reduce(list, %{}, fn {key, val}, map ->
Map.put(map, key, transform(val))
end)
end
def transform({[{_, _}|_] = list}), do: transform(list)
def transform(val), do: val
And then call it with just
transform/1
And the result would be something like:
%{
"App-Version" => "version_here",
"Body" => %{
"CurrentTime" => "2023-02-23T16:40:13+05:30",
"Identification" => %{
"A" => "A-Val",
"B" => "B-Val",
"C" => "C-Val",
"D" => "D-Val"
},
"Names" => ["Name1", "Name2"]
},
"Method" => "method-here",
"TX-ID" => "tx-id-here",
"_id" => "idhere"
}






















