View Source Johnson (Johnson v1.0.0)

Module to encode and decode JSON while preserving the key orders.

Link to this section Summary

Functions

Decode a JSON string, while preserving the original key order.

Transform a struct back to a JSON string.

Get field.

Link to this section Types

@type t() :: %Johnson{data: keyword()}

Link to this section Functions

@spec decode!(binary()) :: t()

Decode a JSON string, while preserving the original key order.

examples

Examples

iex> Johnson.decode!(~s({"a":"a","b":"b"}))
%Johnson{data: [{"a", "a"}, {"b", "b"}]}
@spec encode!(t()) :: binary()

Transform a struct back to a JSON string.

examples

Examples

iex> Johnson.encode!(%Johnson{data: [{"a", "a"}, {"b", "b"}]})
~s({"a":"a","b":"b"})
@spec get(t(), binary()) :: any()

Get field.

examples

Examples

iex> Johnson.get(%Johnson{data: [{"a", "a"}, {"b", "b"}]}, "a")
"a"