diff --git a/src/jsx.erl b/src/jsx.erl index 79682b9..d700bd5 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -60,11 +60,8 @@ format(Source) -> format(Source, []). format(Source, Opts) -> jsx_to_json:format(Source, Opts). --spec to_term(Source::binary()) -> - list({binary(), any()}). --spec to_term(Source::binary(), Opts::jsx_to_term:opts()) -> - list({binary(), any()}). - +-spec to_term(Source::binary()) -> jsx_to_term:json_value(). +-spec to_term(Source::binary(), Opts::jsx_to_term:opts()) -> jsx_to_term:json_value(). to_term(Source) -> to_term(Source, []). diff --git a/src/jsx_to_term.erl b/src/jsx_to_term.erl index 86e9882..4875fee 100644 --- a/src/jsx_to_term.erl +++ b/src/jsx_to_term.erl @@ -33,9 +33,16 @@ -type opts() :: list(). +-type json_value() :: list({binary(), json_value()}) + | list(json_value()) + | true + | false + | null + | integer() + | float() + | binary(). --spec to_term(Source::(binary() | list()), Opts::opts()) -> - list({binary(), any()}). +-spec to_term(Source::binary(), Opts::opts()) -> json_value(). to_term(Source, Opts) when is_list(Opts) -> (jsx:decoder(?MODULE, Opts, jsx_utils:extract_opts(Opts)))(Source).