#ifndef __JSON__JSON__ #define __JSON__JSON__ #include #include #include "json/json.hpp" /** * \author mdejong */ namespace JSON {} namespace JPP { using namespace JSON; } namespace JSON { using nlohmann::json; /** * Load json data from input file. * * \param file_name file name * \param object json data */ inline void load(const std::string& file_name, json& object) { using namespace std; ifstream in(file_name.c_str()); in >> object; in.close(); } /** * Store json data to output file. * * \param file_name file name * \param object json data */ inline void store(const std::string& file_name, const json& object) { using namespace std; ofstream out(file_name.c_str()); out << setw(2) << setprecision(8) << object; out.close(); } /** * Auxiliary class to load json data from file. */ struct JSon : public json { /** * Constructor. * * \param file_name file name */ JSon(const std::string& file_name) { load(file_name, *this); } }; } #endif