json_to_term/2 now returns {incomplete, More} when input ends prematurely rather than an error tuple when called with the option {stream, true}

This commit is contained in:
alisdair sullivan 2011-02-28 12:28:06 -08:00
parent 8ed4b1a405
commit c973abd1b2
2 changed files with 5 additions and 1 deletions

View file

View file

@ -128,7 +128,11 @@ collect({event, Event, Next}, [Key, Current|Rest], Opts) ->
collect({incomplete, More}, [[]], Opts) ->
case More(end_stream) of
{event, Event, _Next} -> event(Event, Opts)
; _ -> erlang:error(badarg)
; _ ->
case proplists:get_value(stream, Opts, false) of
true -> {incomplete, More}
; false -> erlang:error(badarg)
end
end;
%% any other event is an error
collect(_, _, _) -> erlang:error(badarg).