| 109 | } |
| 110 | |
| 111 | bool LoadJsonFromFile( const std::filesystem::path & filePath, Json::Value & outRootNode ) |
| 112 | { |
| 113 | std::ifstream inFile; |
| 114 | inFile.open(filePath); |
| 115 | |
| 116 | if (!inFile.is_open()) |
| 117 | { |
| 118 | inFile.open(filePath); |
| 119 | if (!inFile.is_open()) |
| 120 | { |
| 121 | donut::log::warning("Error attempting to load json file '%s'", filePath.string().c_str()); |
| 122 | return false; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | try { inFile >> outRootNode; } |
| 127 | catch (const Json::RuntimeError& e) |
| 128 | { donut::log::warning("Caught Json::RuntimeError: %s", e.what()); return false; } |
| 129 | catch (const std::exception& e) |
| 130 | { donut::log::warning("Caught std::exception: %s", e.what()); return false; } |
| 131 | return true; |
| 132 | } |
| 133 | |
| 134 | std::string SaveJsonToString( const Json::Value & rootNode ) |
| 135 | { |
no outgoing calls
no test coverage detected