20 ms·
You can skip the last Enum.map/into and just use Map.new: "file.json" |> File.read!() |> Jason.decode!() |> Stream.flat_map(& &1["children"])
by _randyr 3y ago
You can skip the last Enum.map/into and just use Map.new:
"file.json"
|> File.read!()
|> Jason.decode!()
|> Stream.flat_map(& &1["children"])
|> Map.new(fn child -> {child["id"], child} end)