better specs for to_term/x, thanks to michael truog

This commit is contained in:
alisdair sullivan 2012-03-25 13:09:55 -07:00
parent 10c3b1b611
commit cff2ffa295
2 changed files with 24 additions and 6 deletions

View file

@ -60,10 +60,22 @@ 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()) -> list({binary(), any()})
| list(any())
| true
| false
| null
| integer()
| float()
| binary().
-spec to_term(Source::binary(), Opts::jsx_to_term:opts()) -> list({binary(), any()})
| list(any())
| true
| false
| null
| integer()
| float()
| binary().
to_term(Source) -> to_term(Source, []).

View file

@ -34,8 +34,14 @@
-type opts() :: list().
-spec to_term(Source::(binary() | list()), Opts::opts()) ->
list({binary(), any()}).
-spec to_term(Source::binary(), Opts::opts()) -> list({binary(), any()})
| list(any())
| true
| false
| null
| integer()
| float()
| binary().
to_term(Source, Opts) when is_list(Opts) ->
(jsx:decoder(?MODULE, Opts, jsx_utils:extract_opts(Opts)))(Source).