factor out gen_json
This commit is contained in:
parent
61ef73ff72
commit
63faf04115
8 changed files with 20 additions and 184 deletions
|
@ -36,9 +36,12 @@
|
|||
|
||||
-spec is_json(Source::(binary() | list()), Opts::opts()) -> binary().
|
||||
|
||||
is_json(Source, Opts) when (is_binary(Source) andalso is_list(Opts))
|
||||
orelse (is_list(Source) andalso is_list(Opts)) ->
|
||||
try (gen_json:parser(?MODULE, Opts, jsx_utils:extract_opts(Opts)))(Source)
|
||||
is_json(Source, Opts) when is_list(Source) andalso is_list(Opts) ->
|
||||
try (jsx_encoder:encoder(?MODULE, init(Opts), Opts))(Source)
|
||||
catch error:badarg -> false
|
||||
end;
|
||||
is_json(Source, Opts) when is_binary(Source) andalso is_list(Opts) ->
|
||||
try (jsx_decoder:decoder(?MODULE, init(Opts), Opts))(Source)
|
||||
catch error:badarg -> false
|
||||
end.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue