From b57750fcfc9f2cf94a2228c941caea0e74ac85f4 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Sun, 25 Mar 2012 13:18:26 -0700 Subject: [PATCH] fix specs for to_term/x, thanks to michael truog --- src/jsx.erl | 7 ++----- src/jsx_to_term.erl | 11 +++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) 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).