diff --git a/include/jsx_common.hrl b/include/jsx_common.hrl index 793ff23..57e79a7 100644 --- a/include/jsx_common.hrl +++ b/include/jsx_common.hrl @@ -78,12 +78,11 @@ %% this probably doesn't work properly -type jsx_decoder() :: fun((binary()) -> jsx_iterator_result()). - - -type jsx_encoder() :: fun((jsx_encodeable()) -> jsx_iterator_result()). -type jsx_iterator_result() :: {jsx, jsx_event(), fun(() -> jsx_iterator_result())} + | {jsx, [jsx_event()], fun(() -> jsx_iterator_result())} | {jsx, incomplete, jsx_iterator()} | {error, {badjson, any()}}. diff --git a/src/jsx_verify.erl b/src/jsx_verify.erl index bcee490..1e9a3c5 100644 --- a/src/jsx_verify.erl +++ b/src/jsx_verify.erl @@ -35,17 +35,14 @@ -spec is_json(JSON::binary(), Opts::verify_opts()) -> true | false - ; (Terms::list(jsx_encodeable()), Opts::verify_opts()) -> true | false - ; (F::jsx_iterator(), Opts::verify_opts()) -> true | false. + ; (Terms::list(jsx_encodeable()), Opts::verify_opts()) -> true | false. is_json(JSON, OptsList) when is_binary(JSON) -> F = jsx:decoder(extract_parser_opts(OptsList)), verify(F(JSON), parse_opts(OptsList)); is_json(JSON, OptsList) when is_list(JSON) -> F = jsx:encoder(extract_parser_opts(OptsList)), - verify(F(JSON), parse_opts(OptsList)); -is_json(F, OptsList) when is_function(F) -> - verify(jsx_utils:collect(F), parse_opts(OptsList)). + verify(F(JSON), parse_opts(OptsList)). extract_parser_opts(Opts) ->