diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 43cb0003d..95ac1e9e7 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -6523,12 +6523,12 @@ class basic_json { // read width member and use it as indentation parameter if nonzero const bool pretty_print = o.width() > 0; - const auto indentation = pretty_print ? o.width() : 0; + const auto indentation = pretty_print ? o.width() : -1; // reset width to 0 for subsequent calls to this stream o.width(0); - j.dump_to(o, indentation, ' ', false); + j.dump_to(o, indentation, o.fill(), false); return o; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index bc63f9dc8..29b778634 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -22313,12 +22313,12 @@ class basic_json { // read width member and use it as indentation parameter if nonzero const bool pretty_print = o.width() > 0; - const auto indentation = pretty_print ? o.width() : 0; + const auto indentation = pretty_print ? o.width() : -1; // reset width to 0 for subsequent calls to this stream o.width(0); - j.dump_to(o, indentation, ' ', false); + j.dump_to(o, indentation, o.fill(), false); return o; }