JSON文件读取
bool TpsIo::getJsonFromFile(const std::string & path, json & js)
{
std::ifstream is(path.c_str());
if (!is.is_open())
{
LOGE(_("Open json file failed or empty!"))
return false;
}
is >> js;
is.close();
return true;
}
JSON文件写入
json save;
save["CBCT"] = cbct_json;
save["DR1"] = dr_json_1;
save["DR2"] = dr_json_2;
save["GantryAngle"] = dr_config->get_gantry_angle();
std::ofstream save_json("./config/setupConfig.json", std::ios::trunc);
save_json << std::setw(4) << save << std::endl;
save_json.close();