json v1.0.3 JSON View Source

Provides a RFC 7159, ECMA 404, and JSONTestSuite compliant JSON Encoder / Decoder

Link to this section Summary

Functions

Converts a valid JSON string into an Elixir term

Converts a valid JSON string into an Elixir term, raises errors when something bad happens

Returns a JSON string representation of the Elixir term

Returns a JSON string representation of the Elixir term, raises errors when something bad happens

Link to this section Functions

Link to this function decode(bitstring_or_char_list) View Source
decode(bitstring()) :: {atom(), term()}
decode(charlist()) :: {atom(), term()}

Converts a valid JSON string into an Elixir term

Examples

iex> JSON.decode("{\"result\":\"this will be an Elixir result\"}")
{:ok, Enum.into([{"result", "this will be an Elixir result"}], Map.new)}
Link to this function decode!(bitstring_or_char_list) View Source
decode!(bitstring()) :: term()
decode!(charlist()) :: term()

Converts a valid JSON string into an Elixir term, raises errors when something bad happens

Examples

iex> JSON.decode!("{\"result\":\"this will be an Elixir result\"}")
Enum.into([{"result", "this will be an Elixir result"}], Map.new)

Returns a JSON string representation of the Elixir term

Examples

iex> JSON.encode([result: "this will be a JSON result"])
{:ok, "{\"result\":\"this will be a JSON result\"}"}

Returns a JSON string representation of the Elixir term, raises errors when something bad happens

Examples

iex> JSON.encode!([result: "this will be a JSON result"])
"{\"result\":\"this will be a JSON result\"}"