satdump/src-core/nlohmann/json_utils.cpp
2021-07-07 10:26:41 +02:00

24 lines
No EOL
423 B
C++

#include "json.hpp"
#include <fstream>
#include <filesystem>
nlohmann::json loadJsonFile(std::string path)
{
nlohmann::json j;
if (std::filesystem::exists(path))
{
std::ifstream istream(path);
istream >> j;
istream.close();
}
return j;
}
void saveJsonFile(std::string path, nlohmann::json j)
{
std::ofstream ostream(path);
ostream << j.dump(4);
ostream.close();
}