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.
Equivalent to decode_stream_start(JSON, #{}).
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.
Equivalent to iolist_to_binary(format(JSON, Options)).
Formats a binary JSON.
Equivalent to iolist_to_binary(minify_to_iodata(JSON)).
Minifies a binary JSON.
Functions
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">>
Decodes an iodata JSON into a term.
Example:
1> euneus:decode_iodata([$", <<"foo">>, $"]).
<<"foo">>
-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">>
-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}}
-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}
-spec decode_stream_start(JSON) -> Result when JSON :: binary(), Result :: euneus_decoder:stream_result().
Equivalent to decode_stream_start(JSON, #{}).
-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.
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\"">>
Encodes a term into an iodata JSON.
Example:
1> euneus:encode_to_iodata(foo).
[$", <<"foo">>, $"]
-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}">>
-spec format_to_iodata(JSON, Options) -> iodata() when JSON :: binary(), Options :: euneus_formatter:options().
Formats a binary JSON.
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]}">>
Minifies a binary JSON.