Skip to content

Commit

Permalink
Merge pull request #197 from RudolfMan/rm-poison
Browse files Browse the repository at this point in the history
  • Loading branch information
devinus authored May 31, 2024
2 parents af0f395 + 4495364 commit af4ae70
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/poison.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ defmodule Poison do
{:error, exception}
end

@doc """
Encode a value to JSON as iodata.
iex> Poison.encode_to_iodata([1, 2, 3])
{:ok, [91, ["1", 44, "2", 44, "3"], 93]}
"""
@spec encode_to_iodata(Encoder.t, Keyword.t) :: {:ok, iodata} | {:error, {:invalid, any}}
def encode_to_iodata(value, options \\ []) do
encode(value, [iodata: true] ++ options)
end

@doc """
Encode a value to JSON, raises an exception on error.
Expand All @@ -45,6 +56,17 @@ defmodule Poison do
end
end

@doc """
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]
"""
@spec encode_to_iodata!(Encoder.t, Keyword.t) :: iodata | no_return
def encode_to_iodata!(value, options \\ []) do
encode!(value, [iodata: true] ++ options)
end

@doc """
Decode JSON to a value.
Expand Down

0 comments on commit af4ae70

Please sign in to comment.