View Source euneus_encoder (euneus v0.3.0)

Encode Erlang terms to JSON.

Summary

Types

-type encode_fun(Input) :: fun((Input, options()) -> iolist()).
-type error_reason() ::
    {unsupported_type, Unsupported :: term()} | {invalid_byte, Byte :: byte(), Input :: binary()}.
-type escape_fun(Input) :: fun((Input, options()) -> iolist()).
-type input() :: term().
-type options() ::
    #{null_terms => list(),
      encode_binary => encode_fun(Input :: binary()),
      encode_atom => encode_fun(Input :: atom()),
      encode_integer => encode_fun(Input :: integer()),
      encode_float => encode_fun(Input :: float()),
      encode_list => encode_fun(Input :: list()),
      encode_map => encode_fun(Input :: map()),
      encode_datetime => encode_fun(Input :: calendar:datetime()),
      encode_timestamp => encode_fun(Input :: erlang:timestamp()),
      encode_unhandled => encode_fun(Input :: term()),
      escape_binary => escape_fun(Input :: binary())}.
-type result() :: {ok, iolist()} | {error, error_reason()}.

Functions

-spec encode(Term, Opts) -> Return when Term :: term(), Opts :: options(), Return :: result().
Link to this function

encode_binary(Bin, Opts)

View Source
Link to this function

encode_datetime(_, Opts)

View Source
Link to this function

encode_float(Float, Opts)

View Source
Link to this function

encode_integer(Int, Opts)

View Source
Link to this function

encode_timestamp(Timestamp, Opts)

View Source
Link to this function

encode_unhandled(Term, Opts)

View Source
Link to this function

escape_binary(Bin, Opts)

View Source
Link to this function

throw_unsupported_type_error(Term)

View Source