We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents af0f395 + 4495364 commit af4ae70Copy full SHA for af4ae70
lib/poison.ex
@@ -24,6 +24,17 @@ defmodule Poison do
24
{:error, exception}
25
end
26
27
+ @doc """
28
+ Encode a value to JSON as iodata.
29
+
30
+ iex> Poison.encode_to_iodata([1, 2, 3])
31
+ {:ok, [91, ["1", 44, "2", 44, "3"], 93]}
32
+ """
33
+ @spec encode_to_iodata(Encoder.t, Keyword.t) :: {:ok, iodata} | {:error, {:invalid, any}}
34
+ def encode_to_iodata(value, options \\ []) do
35
+ encode(value, [iodata: true] ++ options)
36
+ end
37
38
@doc """
39
Encode a value to JSON, raises an exception on error.
40
@@ -45,6 +56,17 @@ defmodule Poison do
45
56
46
57
47
58
59
60
+ Encode a value to JSON as iodata, raises an exception on error.
61
62
+ iex> Poison.encode_to_iodata!([1, 2, 3])
63
+ [91, ["1", 44, "2", 44, "3"], 93]
64
65
+ @spec encode_to_iodata!(Encoder.t, Keyword.t) :: iodata | no_return
66
+ def encode_to_iodata!(value, options \\ []) do
67
+ encode!(value, [iodata: true] ++ options)
68
69
48
70
49
71
Decode JSON to a value.
50
72
0 commit comments