View Source euneus_encoder (euneus v0.4.0)

Encode Erlang terms to JSON.

Summary

Types

-type encoder(Input) :: fun((Input, options()) -> iolist()).
-type error_class() :: error | exit | throw.
-type error_handler() ::
    fun((error_class(), error_reason(), error_stacktrace(), input(), options()) ->
            error_stacktrace()).
-type error_reason() ::
    {unsupported_type, Unsupported :: term()} | {invalid_byte, Byte :: byte(), Input :: binary()}.
-type error_stacktrace() :: erlang:stacktrace().
-type escaper(Input) :: fun((Input, options()) -> iolist()).
-type input() :: term().
-type options() ::
    #{nulls => list(),
      binary_encoder => encoder(Input :: binary()),
      atom_encoder => encoder(Input :: atom()),
      integer_encoder => encoder(Input :: integer()),
      float_encoder => encoder(Input :: float()),
      list_encoder => encoder(Input :: list()),
      map_encoder => encoder(Input :: map()),
      datetime_encoder => encoder(Input :: calendar:datetime()),
      timestamp_encoder => encoder(Input :: erlang:timestamp()),
      unhandled_encoder => encoder(Input :: term()),
      escaper => escaper(Input :: binary()),
      error_handler => error_handler()}.
-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

handle_error(Class, Reason, Stacktrace)

View Source
Link to this function

throw_unsupported_type_error(Term)

View Source