Does it make sense to setstd::ios_base::failbitto throw exceptions, for output streams? As in: 1 2 3 4 5 std::ofstream output_file("out.txt"); output_file.exceptions(std::ios_base::badbit | std::ios_base::failbit);// ... ...
catch (const std::ios_base::failure &e) { std::cerr << e.code().message() << std::endl; } The line (*) produce std::ios_base::failure exception when parse function reaches end of stream even if json document is valid. Without std::ios_base::failbit function works OK.nlohmann ...