%% @author William Fank Thomé %% @copyright 2023 William Fank Thomé %% @doc Core module to parse and generate JSON. %% 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. -module(euneus). -compile({inline, [ encode/2, encode_to_binary/2, decode/2 ]}). -export([ encode/1, encode/2 ]). -export([ encode_to_binary/1, encode_to_binary/2 ]). -export([ decode/1, decode/2 ]). -spec encode(Input) -> Return when Input :: euneus_encoder:input(), Return :: euneus_encoder:result(). encode(Input) -> encode(Input, #{}). -spec encode(Input, Opts) -> Return when Input :: euneus_encoder:input(), Opts :: euneus_encoder:options(), Return :: euneus_encoder:result(). encode(Input, Opts) -> euneus_encoder:encode(Input, Opts). -spec encode_to_binary(Input) -> Return when Input :: euneus_encoder:input(), Return :: {ok, binary()} | {error, euneus_encoder:error_reason()}. encode_to_binary(Input) -> encode_to_binary(Input, #{}). -spec encode_to_binary(Input, Opts) -> Return when Input :: euneus_encoder:input(), Opts :: euneus_encoder:options(), Return :: {ok, binary()} | {error, euneus_encoder:error_reason()}. encode_to_binary(Input, Opts) -> case encode(Input, Opts) of {ok, Result} -> {ok, iolist_to_binary(Result)}; {error, Reason} -> {error, Reason} end. -spec decode(Input) -> Result when Input :: euneus_decoder:input(), Result :: euneus_decoder:result(). decode(Input) -> decode(Input, #{}). -spec decode(Input, Opts) -> Result when Input :: euneus_decoder:input(), Opts :: euneus_decoder:options(), Result :: euneus_decoder:result(). decode(Input, Opts) -> euneus_decoder:decode(Input, Opts).