Added ability to supply JSON from standard input

This commit is contained in:
2026-03-30 17:28:36 +03:00
parent a80e23614d
commit 6b22d8465e
4 changed files with 40 additions and 6 deletions

View File

@@ -141,15 +141,20 @@ bool read_config_json(json& cfg, const string& filename, ostream* log)
{
if (nullptr != log)
{
*log << "Could not open config.json" << endl;
*log << "Could not open config file" << endl;
}
return false;
}
return read_config_json(cfg, cfg_file, log);
}
bool read_config_json(json& cfg, istream& in, ostream* log)
{
// Parse with comments
try
{
cfg = json::parse(cfg_file, nullptr, true, true);
cfg = json::parse(in, nullptr, true, true);
}
catch (const std::exception &e)
{