View Source Blazer (blazer v0.1.1)

Blazer is a case parser for json keys.

available case options:

  • :camel example: camelCase
  • :pascal example: PascalCase
  • :snake example: snake_case
  • :upper example: UPPERCASE
  • :kebab example: kebab-case
  • :title example: Title Case

Link to this section Summary

Functions

Decode a JSON into a map and parse its keys

encode a map into JSON after parsing its keys

Parses a map or a string to the desired case

Link to this section Types

Specs

opts() :: [
  case: :camel | :pascal | :snake | :upper | :kebab | :title,
  keys: :strings | :atoms | :atoms!
]

Link to this section Functions

Link to this function

decode(json, opts \\ [])

View Source

Specs

decode(String.t(), opts()) :: {:ok, map()} | {:error, String.t()}

Decode a JSON into a map and parse its keys

opts is passed to Jason, so all its options can be used

Link to this function

decode!(json, opts \\ [])

View Source

Specs

decode!(String.t(), opts()) :: map()
Link to this function

encode(term, opts \\ [])

View Source

Specs

encode(map(), opts()) :: {:ok, String.t()} | {:error, String.t()}

encode a map into JSON after parsing its keys

opts is passed to Jason, so all its options can be used

Link to this function

encode!(term, opts \\ [])

View Source

Specs

encode!(map(), opts()) :: String.t()
Link to this function

encode_to_iodata!(term, opts \\ [])

View Source

Specs

encode_to_iodata!(map(), opts()) :: [...]

Specs

parse(String.t() | map(), Blazer.Structs.Opts.t()) ::
  {:ok, String.t() | map()} | {:error, String.t()}

Parses a map or a string to the desired case

iex(1)> Blazer.parse(%{"firstKey" => "data", "secondKey" => "data"}, case: :snake, keys: :atoms)
{:ok, %{first_key: "data", second_key: "data"}}

iex(2)> Blazer.parse("john_doe", case: :title)
{:ok, "John Doe"}

Specs

parse!(String.t() | map(), Blazer.Structs.Opts.t()) :: String.t() | map()