Skip to content

Instantly share code, notes, and snippets.

View aikomastboom's full-sized avatar

Aiko Mastboom aikomastboom

View GitHub Profile
@aikomastboom
aikomastboom / json_map_builder.ex
Last active October 16, 2021 19:49 — forked from rcdilorenzo/json_map_builder.ex
Convert a elixir json-decoded object to a map no matter how deep
defmodule JSONMapBuilder do
def to_map(list) when is_list(list) and length(list) > 0 do
case list
|> List.first do
{_, _} ->
Enum.reduce(
list,
%{},
fn (tuple, acc) ->
{key, value} = tuple_to_key_value(tuple)