View Source Jsonrs (jsonrs v0.2.1)
A JSON library powered by Rust's Serde through a NIF
Link to this section Summary
Functions
Parses a JSON value from input
string.
Parses a JSON value from input
string.
Generates JSON corresponding to input
.
Generates JSON corresponding to input
.
Identical to encode!/1
. Exists to implement Phoenix interface and encodes to a single normal string.
Identical to encode/1
. Exists to implement Phoenix interface and encodes to a single normal string.
Link to this section Functions
Parses a JSON value from input
string.
Similar to decode/2
except it will raise in case of errors.
examples
Examples
iex> Jsonrs.decode!("{\"x\":[1,2]}")
%{"x" => [1, 2]}
iex> Jsonrs.decode!("invalid")
** (ErlangError) Erlang error: "expected value at line 1 column 1"
Parses a JSON value from input
string.
examples
Examples
iex> Jsonrs.decode("{\"x\":[1,2]}")
{:ok, %{"x" => [1, 2]}}
iex> Jsonrs.decode("invalid")
{:error, "expected value at line 1 column 1"}
Generates JSON corresponding to input
.
Similar to encode/1
except it will raise in case of errors.
examples
Examples
iex> Jsonrs.encode!(%{"x" => [1,2]})
"{\"x\":[1,2]}"
iex> Jsonrs.encode!("\xFF")
** (ErlangError) Erlang error: :encode_error
Generates JSON corresponding to input
.
examples
Examples
iex> Jsonrs.encode(%{"x" => [1,2]})
{:ok, "{\"x\":[1,2]}"}
iex> Jsonrs.encode("\xFF")
{:error, :encode_error}
Identical to encode!/1
. Exists to implement Phoenix interface and encodes to a single normal string.
Identical to encode/1
. Exists to implement Phoenix interface and encodes to a single normal string.