json: Make eof detection proper.