better specs for to_term/x, thanks to michael truog
This commit is contained in:
parent
10c3b1b611
commit
cff2ffa295
2 changed files with 24 additions and 6 deletions
20
src/jsx.erl
20
src/jsx.erl
|
@ -60,10 +60,22 @@ format(Source) -> format(Source, []).
|
||||||
format(Source, Opts) -> jsx_to_json:format(Source, Opts).
|
format(Source, Opts) -> jsx_to_json:format(Source, Opts).
|
||||||
|
|
||||||
|
|
||||||
-spec to_term(Source::binary()) ->
|
-spec to_term(Source::binary()) -> list({binary(), any()})
|
||||||
list({binary(), any()}).
|
| list(any())
|
||||||
-spec to_term(Source::binary(), Opts::jsx_to_term:opts()) ->
|
| true
|
||||||
list({binary(), any()}).
|
| 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, []).
|
to_term(Source) -> to_term(Source, []).
|
||||||
|
|
|
@ -34,8 +34,14 @@
|
||||||
-type opts() :: list().
|
-type opts() :: list().
|
||||||
|
|
||||||
|
|
||||||
-spec to_term(Source::(binary() | list()), Opts::opts()) ->
|
-spec to_term(Source::binary(), Opts::opts()) -> list({binary(), any()})
|
||||||
list({binary(), any()}).
|
| list(any())
|
||||||
|
| true
|
||||||
|
| false
|
||||||
|
| null
|
||||||
|
| integer()
|
||||||
|
| float()
|
||||||
|
| binary().
|
||||||
|
|
||||||
to_term(Source, Opts) when is_list(Opts) ->
|
to_term(Source, Opts) when is_list(Opts) ->
|
||||||
(jsx:decoder(?MODULE, Opts, jsx_utils:extract_opts(Opts)))(Source).
|
(jsx:decoder(?MODULE, Opts, jsx_utils:extract_opts(Opts)))(Source).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue