20inline void write_json_file(
const std::string& path,
const nlohmann::json& document) {
21 const std::filesystem::path file_path(path);
22 if (file_path.has_parent_path()) {
23 std::filesystem::create_directories(file_path.parent_path());
25 std::ofstream stream(file_path);
26 if (!stream.is_open()) {
27 throw std::runtime_error(
"write_json_file: cannot open '" + path +
"' for writing");
29 stream << document.dump(4) <<
"\n";
30 log::info(
" Results written to: {}", path);