Popularity
3.3
Declining
Activity
0.0
Stable
17
4
4

Monthly Downloads: 2,248
Programming language: Elixir
License: BSD 3-clause "New" or "Revised" License
Latest version: v0.2.4

Mappable alternatives and similar packages

Based on the "Algorithms and Data structures" category.
Alternatively, view Mappable alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Mappable or a related project?

Add another 'Algorithms and Data structures' Package

README

Mappable

Simple module that provides unified, simple interface for converting between different dictionary-like data types in Elixir:

  • maps
  • structs
  • keyword lists

Examples

Use Mappable.to_map map, keys: :strings to convert anything to map with string keys recursively:

%{:foo => :bar}
|> Mappable.to_map(keys: :strings)
=> %{"foo" => :bar}

Use keys: :atoms to do the same but use atom keys:

%{"foo" => %{"bar" => :baz}}
|> Mappable.to_map(keys: :atoms)
=> %{:foo => %{:bar => :baz}}

Convert anything to struct easily by matching keys:

%{"id" => 1, "email" => "[email protected]"}
|> Mappable.to_struct(User)
=> %User{id: 1, email: "jack@[email protected]"}

Convert anything to keyword list with:

%{"bar" => :foo, "foo" => :bar}
> Mappable.to_list
=> [bar: :foo, foo: :bar]

Installation

If available in Hex, the package can be installed by adding mappable to your list of dependencies in mix.exs:

def deps do
  [{:mappable, "~> 0.2.0"}]
end

Documentation

Documentation on HexDocs.