Hello,
Welcome to the forum
This may help you
from_struct(struct)View Source
from_struct(atom() | struct()) :: map()
Converts a struct to map.
It accepts the struct module or a struct itself and simply removes the __struct__ field from the given struct or from a new struct generated from the given module.
Example
defmodule User do
defstruct [:name]
end
Map.from_struct(User)
#=> %{name: nil}
Map.from_struct(%User{name: "john"})
#=> %{name: "john"}


















