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).
|
||||
|
||||
|
||||
-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, []).
|
||||
|
|
|
@ -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).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue