Skip to content

Latest commit

 

History

History
50 lines (32 loc) · 1.21 KB

README.md

File metadata and controls

50 lines (32 loc) · 1.21 KB

Blazer

Blazer is a fast case parser for maps, strings and JSON using NIFs.

Useful to consume camel/pascal cased APIs while still using elixir's snake case convention

Uses Jason to parse the json data.

Documentation

Installation

It can be installed by adding blazer to your list of dependencies in mix.exs:

def deps do
  [
    {:blazer, "~> 0.1.1"}
  ]
end

Basic Usage

iex(1)> Blazer.parse(%{"categoryId" => 13, "profileName" => "hammsvietro"}, case: :snake)
{:ok, %{category_id: 13, profile_name: "hammsvietro"}}


iex(2)> Jason.encode!(%{"category_id" => 13, "profile_name" => "hammsvietro"}, case: :camel))
"{\"categoryId\":13,\"profileName\":\"hammsvietro\"}"

Usage with Phoenix

In your config.exs:

config :blazer, inner_case: :snake, outer_case: :camel
config :phoenix, :json_library, Blazer

There you go! Now every map key will use elixir's standard snake case while externally the API will produce/consume camel cased properties

Contributing

Contributions are very welcome! Feel free to open an issue =)

License

Blazer source code is licensed under the MIT License.