View Source euneus_decoder (euneus v1.2.0)
JSON parser.
Copyright 2023 William Fank Thomé
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.Summary
Functions
Parses JSON to Erlang term.
Parses JSON to Erlang term.
Handles decoding errors.
Resumes the decoding after a token error.
Resumes the decoding after a token error.
Types
-type error_class() :: error | exit | throw.
-type error_handler() :: fun((error_class(), error_reason(), error_stacktrace()) -> error_stacktrace()).
-type error_reason() :: unexpected_end_of_input_error() | unexpected_byte_error() | unexpected_sequence_error() | invalid_option_error().
-type error_stacktrace() :: erlang:stacktrace().
-type input() :: binary() | iolist().
-type invalid_option_error() :: {invalid_option, term()}.
-type normalizer(Term) :: fun((Term, parsed_options()) -> term()).
-type options() :: map().
-type parsed_options() :: #opts{}.
-type plugin() :: datetime | inet | pid | port | reference | timestamp | module().
-type position() :: non_neg_integer().
-type result() :: {ok, term()} | {error, error_reason()}.
-type unexpected_byte_error() :: {unexpected_byte, binary(), position()}.
-type unexpected_end_of_input_error() :: unexpected_end_of_input.
-type unexpected_sequence_error() :: {unexpected_sequence, binary(), position()}.
Functions
-spec decode_parsed(input(), parsed_options()) -> result().
-spec handle_error(Class, Reason, Stacktrace) -> Result when Class :: error | exit | throw, Reason :: term(), Stacktrace :: erlang:stacktrace(), Result :: {error, term()} | no_return().
-spec parse_opts(options()) -> parsed_options().
Parses euneus_decoder:options()
to euneus_decoder:parsed_options()
.
-spec resume(Token, Rest, Opts, Input, Pos, Buffer) -> Result when Token :: binary(), Rest :: bitstring(), Opts :: parsed_options(), Input :: binary(), Pos :: non_neg_integer(), Buffer :: list(), Result :: result().
Resumes the decoding after a token error.
Passes the null_term option as the Replacement argument ofeuneus_decoder:resume/7
.
-spec resume(Token, Replacement, Rest, Opts, Input, Pos, Buffer) -> Result when Token :: binary(), Replacement :: term(), Rest :: bitstring(), Opts :: parsed_options(), Input :: binary(), Pos :: non_neg_integer(), Buffer :: list(), Result :: result().