diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 8b8c68636b..5775d3e6a0 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -435,7 +435,11 @@ inline void to_json(BasicJsonType& j, const T& t) template inline void to_json(BasicJsonType& j, const std_fs::path& p) { - j = p.string(); +#if defined __cpp_lib_char8_t + j = reinterpret_cast(p.u8string().data()); +#else + j = p.u8string(); +#endif } #endif