How detect end of file while reading JSON?

I am about to do some streaming reading of JSON terms.
Is there an option or a way to detect end of file in SWI-
Prolog while reading JSON. Currently it gives me an error:

?- current_input(S), json_read(S, X).
ERROR: Stream <stream>(00007ff8ec6ce560):17:3 
Syntax error: json(unexpected_end_of_file)

Was rather expecting some special result, like end_of_file.
Problem is, what if the file contains some white space, an eof
check via at_end_of_stream/1 would not give the correct result.

Edit 15.04.2023
Ok my bad. There is an option to do that:

?- current_input(S), json_read(S, X, [end_of_file(end_of_file)]).
X = end_of_file.