9021{
9022 try {
9023 boost::nowide::ifstream ifs(
path);
9024 if (!ifs.good())
9025 return false;
9026
9028 ifs >> j;
9029
9030 if (j.contains("id")) this->id = j["id"].get<std::string>();
9031
9032 if (j.contains(
"name")) this->
name = j[
"name"].get<std::string>();
9033 else if (j.contains(
"bundle_id")) this->
name = j[
"bundle_id"].get<std::string>();
9034
9035 if (j.contains(
"version")) this->
version = j[
"version"].get<std::string>();
9036
9037 if (j.contains(
"description")) this->
description = j[
"description"].get<std::string>();
9038 else if (j.contains(
"bundle_type")) this->
description = j[
"bundle_type"].get<std::string>();
9039
9040 if (j.contains(
"author")) this->
author = j[
"author"].get<std::string>();
9041
9042 if (j.contains(
"imported_time")) this->
imported_time = j[
"imported_time"].get<
long long>();
9043
9044 if (j.contains(
"updated_time")) this->
updated_time = j[
"updated_time"].get<
long long>();
9045
9046 if (j.contains("print_presets"))
9047 this->
print_presets = j[
"print_presets"].get<std::vector<std::string>>();
9048
9049 if (j.contains("filament_presets"))
9050 this->
filament_presets = j[
"filament_presets"].get<std::vector<std::string>>();
9051
9052 if (j.contains("printer_presets"))
9053 this->
printer_presets = j[
"printer_presets"].get<std::vector<std::string>>();
9054
9055 return true;
9056 } catch (const std::exception& e) {
9057 BOOST_LOG_TRIVIAL(error) <<
"Failed to load bundle metadata from " <<
path <<
": " << e.what();
9058 return false;
9059 }
9060}
nlohmann::json json
Definition AssembleList.cpp:42