View Source euneus_encoder (euneus v0.5.1)

JSON generator.

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

unsupported_type_error/0

View Source
-type unsupported_type_error() :: {unsupported_type, Unsupported :: term()}.

Functions

-spec encode(term(), options()) -> 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_parsed(Term, Opts)

View Source
-spec encode_parsed(term(), options()) -> result().
Link to this function

encode_timestamp(Timestamp, Opts)

View Source
Link to this function

encode_unhandled(Term, Opts)

View Source
Link to this function

handle_error(Class, Reason, Stacktrace)

View Source
-spec parse_opts(map()) -> options().
Link to this function

throw_unsupported_type_error(Term)

View Source