View Source euneus (euneus v2.4.0)

Summary

Functions

Decodes a binary JSON into a term.

Decodes a binary JSON into a term.

Decodes an iodata JSON into a term.

Decodes an iodata JSON into a term.

Encodes a term into a binary JSON.

Encodes a term into a binary JSON.

Encodes a term into an iodata JSON.

Encodes a term into an iodata JSON.

Formats a binary JSON.

Minifies a binary JSON.

Functions

-spec decode(JSON) -> term() when JSON :: binary().

Decodes a binary JSON into a term.

Example:

  1> euneus:decode(<<"\"foo\"">>).
  <<"foo">>
-spec decode(JSON, Options) -> term() when JSON :: binary(), Options :: euneus_decoder:options().

Decodes a binary JSON into a term.

Example:

  1> euneus:decode(<<"\"foo\"">>, #{}).
  <<"foo">>
-spec decode_iodata(JSON) -> term() when JSON :: iodata().

Decodes an iodata JSON into a term.

Example:

  1> euneus:decode_iodata([$", <<"foo">>, $"]).
  <<"foo">>
Link to this function

decode_iodata(JSON, Options)

View Source
-spec decode_iodata(JSON, Options) -> term() when JSON :: iodata(), Options :: euneus_decoder:options().

Decodes an iodata JSON into a term.

Example:

  1> euneus:decode_iodata([$", <<"foo">>, $"], #{}).
  <<"foo">>
Link to this function

decode_stream_continue(JSON, State)

View Source
-spec decode_stream_continue(JSON, State) -> Result
                                when
                                    JSON :: binary() | end_of_input,
                                    State :: euneus_decoder:stream_state(),
                                    Result :: euneus_decoder:stream_result().

Equivalent to euneus_decoder:stream_continue(JSON, State).

Continue parsing a stream of bytes of a JSON value.

Example:

  1> begin
  .. {continue, State} = euneus:decode_stream_start(<<"{\"foo\":">>),
  .. euneus:decode_stream_continue(<<"1}">>, State)
  .. end.
  {end_of_input,#{<<"foo">> => 1}}
Link to this function

decode_stream_end(State)

View Source
-spec decode_stream_end(State) -> Result
                           when State :: euneus_decoder:stream_state(), Result :: {end_of_input, term()}.

Equivalent to euneus_decoder:stream_continue(end_of_input, State).

Ends parsing a stream of bytes of a JSON value.

Example:

  1> begin
  .. {continue, State} = euneus:decode_stream_start(<<"123">>),
  .. euneus:decode_stream_end(State)
  .. end.
  {end_of_input,123}
Link to this function

decode_stream_start(JSON)

View Source
-spec decode_stream_start(JSON) -> Result
                             when JSON :: binary(), Result :: euneus_decoder:stream_result().

Equivalent to decode_stream_start(JSON, #{}).

Link to this function

decode_stream_start(JSON, Options)

View Source
-spec decode_stream_start(JSON, Options) -> Result
                             when
                                 JSON :: binary(),
                                 Options :: euneus_decoder:options(),
                                 Result :: euneus_decoder:stream_result().

Equivalent to euneus_decoder:stream_start(JSON, Options).

Begin parsing a stream of bytes of a JSON value.

-spec encode(Term) -> binary() when Term :: term().

Encodes a term into a binary JSON.

Example:

  1> euneus:encode(foo).
  <<"\"foo\"">>
-spec encode(Term, Options) -> binary() when Term :: term(), Options :: euneus_encoder:options().

Encodes a term into a binary JSON.

Example:

  1> euneus:encode(foo, #{}).
  <<"\"foo\"">>
-spec encode_to_iodata(Term) -> iodata() when Term :: term().

Encodes a term into an iodata JSON.

Example:

  1> euneus:encode_to_iodata(foo).
  [$", <<"foo">>, $"]
Link to this function

encode_to_iodata(Term, Options)

View Source
-spec encode_to_iodata(Term, Options) -> iodata()
                          when Term :: term(), Options :: euneus_encoder:options().

Encodes a term into an iodata JSON.

Example:

  1> euneus:encode_to_iodata(foo, #{}).
  [$", <<"foo">>, $"]
-spec format(JSON, Options) -> binary() when JSON :: binary(), Options :: euneus_formatter:options().

Equivalent to iolist_to_binary(format(JSON, Options)).

Formats a binary JSON.

Example:

  1> Opts = #{
  ..     indent_type => tabs,
  ..     indent_width => 1,
  ..     spaced_values => true,
  ..     crlf => n
  .. }.
  #{indent_type => tabs,indent_width => 1,spaced_values => true, crlf => n}
  2> euneus:format(<<" \n{\"foo\"  :  [ true  , \n null ] \n  }  ">>, Opts).
  <<"{\n\t\"foo\": [\n\t\ttrue,\n\t\tnull\n\t]\n}">>
Link to this function

format_to_iodata(JSON, Options)

View Source
-spec format_to_iodata(JSON, Options) -> iodata()
                          when JSON :: binary(), Options :: euneus_formatter:options().

Formats a binary JSON.

-spec minify(JSON) -> binary() when JSON :: binary().

Equivalent to iolist_to_binary(minify_to_iodata(JSON)).

Minifies a binary JSON.

Example:

  1> euneus:minify(<<" \n{\"foo\"  :  [ true  , \n null ] \n  }  ">>).
  <<"{\"foo\":[true,null]}">>
-spec minify_to_iodata(JSON) -> iodata() when JSON :: binary().

Minifies a binary JSON.