poison v2.2.0 Poison
Summary
Functions
Decode JSON to a value
Decode JSON to a value, raises an exception on error
Encode a value to JSON
Encode a value to JSON, raises an exception on error
Encode a value to JSON as iodata
Encode a value to JSON as iodata, raises an exception on error
Functions
Specs
decode(iodata, Keyword.t) ::
{:ok, Poison.Parser.t} |
{:error, :invalid} |
{:error, {:invalid, String.t}}
Decode JSON to a value.
iex> Poison.decode("[1,2,3]")
{:ok, [1, 2, 3]}
Specs
decode!(iodata, Keyword.t) ::
Poison.Parser.t |
no_return
Decode JSON to a value, raises an exception on error.
iex> Poison.decode!("[1,2,3]")
[1, 2, 3]
Specs
encode(Poison.Encoder.t, Keyword.t) ::
{:ok, iodata} |
{:ok, String.t} |
{:error, {:invalid, any}}
Encode a value to JSON.
iex> Poison.encode([1, 2, 3])
{:ok, "[1,2,3]"}
Specs
encode!(Poison.Encoder.t, Keyword.t) ::
iodata |
no_return
Encode a value to JSON, raises an exception on error.
iex> Poison.encode!([1, 2, 3])
"[1,2,3]"
Specs
encode_to_iodata(Poison.Encoder.t, Keyword.t) ::
{:ok, iodata} |
{:error, {:invalid, any}}
Encode a value to JSON as iodata.
iex> Poison.encode_to_iodata([1, 2, 3])
{:ok, [91, ["1", 44, "2", 44, "3"], 93]}
Specs
encode_to_iodata!(Poison.Encoder.t, Keyword.t) ::
iodata |
no_return
Encode a value to JSON as iodata, raises an exception on error.
iex> Poison.encode_to_iodata!([1, 2, 3])
[91, ["1", 44, "2", 44, "3"], 93]