format/1,2 takes a list of terms as an argument now, in addition to binary json or a jsx_iterator
This commit is contained in:
parent
9cee07212f
commit
04dfde559e
1 changed files with 9 additions and 2 deletions
|
@ -33,12 +33,19 @@
|
|||
|
||||
|
||||
|
||||
-spec format(JSON::binary(), Opts::format_opts()) -> binary() | iolist()
|
||||
; (F::jsx_iterator(), Opts::format_opts()) -> binary() | iolist().
|
||||
-spec format(JSON::binary(), Opts::format_opts()) ->
|
||||
binary() | iolist()
|
||||
; (Terms::list(jsx_encodeable()), Opts::format_opts()) ->
|
||||
binary() | iolist()
|
||||
; (F::jsx_iterator(), Opts::format_opts()) ->
|
||||
binary() | iolist().
|
||||
|
||||
format(JSON, OptsList) when is_binary(JSON) ->
|
||||
P = jsx:decoder(extract_parser_opts(OptsList)),
|
||||
format(fun() -> P(JSON) end, OptsList);
|
||||
format(Terms, OptsList) when is_list(Terms) ->
|
||||
P = jsx:encoder(),
|
||||
format(fun() -> P(Terms) end, OptsList);
|
||||
format(F, OptsList) when is_function(F) ->
|
||||
Opts = parse_opts(OptsList, #format_opts{}),
|
||||
{Continue, String} = format_something(F(), Opts, 0),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue