Reduce size by Json Fromatting (#13163)
Reduce the size of current and new JSONs by standardising them with 1 tab indentation instead of 4 spaces. This effectively reduces the size by almost 20 MB. | Current | New | |---|---| | 85.2 Mib | 67 Mib | Used [JQ](https://jqlang.org/) `--tab` to automatically format every current JSON. > [!NOTE] > Some profiles had the arrays on the same line, but those created by Orca were in the standard format (each object below the previous one). In some cases, this increases the number of tabs due to the new lines, but the increase is negligible, and this way both the base profiles and those created by Orca maintain the same style.
This commit is contained in:
@@ -446,7 +446,7 @@ void record_exit_reson(std::string outputdir, int code, int plate_id, std::strin
|
||||
|
||||
boost::nowide::ofstream c;
|
||||
c.open(result_file, std::ios::out | std::ios::trunc);
|
||||
c << std::setw(4) << j << std::endl;
|
||||
c << j.dump(1, '\t') << std::endl;
|
||||
c.close();
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" <<__LINE__ << boost::format(", saved config to %1%\n")%result_file;
|
||||
|
||||
@@ -941,13 +941,13 @@ void AppConfig::save()
|
||||
}
|
||||
boost::nowide::ofstream c;
|
||||
c.open(path_pid, std::ios::out | std::ios::trunc);
|
||||
c << std::setw(4) << j << std::endl;
|
||||
c << j.dump(1, '\t') << std::endl;
|
||||
|
||||
#ifdef WIN32
|
||||
// WIN32 specific: The final "rename_file()" call is not safe in case of an application crash, there is no atomic "rename file" API
|
||||
// provided by Windows (sic!). Therefore we save a MD5 checksum to be able to verify file corruption. In addition,
|
||||
// we save the config file into a backup first before moving it to the final destination.
|
||||
c << appconfig_md5_hash_line(j.dump(4));
|
||||
c << appconfig_md5_hash_line(j.dump(1, '\t'));
|
||||
#endif
|
||||
|
||||
c.close();
|
||||
|
||||
@@ -1498,7 +1498,7 @@ void ConfigBase::save_to_json(const std::string &file, const std::string &name,
|
||||
|
||||
boost::nowide::ofstream c;
|
||||
c.open(file, std::ios::out | std::ios::trunc);
|
||||
c << std::setw(4) << j << std::endl;
|
||||
c << j.dump(1, '\t') << std::endl;
|
||||
c.close();
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" <<__LINE__ << boost::format(", saved config to %1%\n")%file;
|
||||
|
||||
@@ -4598,7 +4598,7 @@ int Print::export_cached_data(const std::string& directory, bool with_space)
|
||||
/*boost::nowide::ofstream c;
|
||||
c.open(file_name, std::ios::out | std::ios::trunc);
|
||||
if (with_space)
|
||||
c << std::setw(4) << root_json << std::endl;
|
||||
c << root_json.dump(1, '\t') << std::endl;
|
||||
else
|
||||
c << root_json.dump(0) << std::endl;
|
||||
c.close();*/
|
||||
@@ -4620,7 +4620,7 @@ int Print::export_cached_data(const std::string& directory, bool with_space)
|
||||
boost::nowide::ofstream c;
|
||||
c.open(filename_vector[object_index], std::ios::out | std::ios::trunc);
|
||||
if (with_space)
|
||||
c << std::setw(4) << json_vector[object_index] << std::endl;
|
||||
c << json_vector[object_index].dump(1, '\t') << std::endl;
|
||||
else
|
||||
c << json_vector[object_index].dump(0) << std::endl;
|
||||
c.close();
|
||||
|
||||
@@ -242,7 +242,7 @@ int HMSQuery::save_to_local(std::string lang, std::string hms_type, std::string
|
||||
std::string dir_str = (hms_folder / filename).make_preferred().string();
|
||||
std::ofstream json_file(encode_path(dir_str.c_str()));
|
||||
if (json_file.is_open()) {
|
||||
json_file << std::setw(4) << save_json << std::endl;
|
||||
json_file << save_json.dump(1, '\t') << std::endl;
|
||||
json_file.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -627,7 +627,7 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str
|
||||
|
||||
boost::nowide::ofstream c;
|
||||
c.open(changelog_file, std::ios::out | std::ios::trunc);
|
||||
c << std::setw(4) << j << std::endl;
|
||||
c << j.dump(1, '\t') << std::endl;
|
||||
c.close();
|
||||
}
|
||||
catch(std::exception &err) {
|
||||
|
||||
@@ -166,7 +166,7 @@ void SimplyPrint::save_oauth_credential(const GUI::OAuthResult& cred) const
|
||||
|
||||
boost::nowide::ofstream c;
|
||||
c.open(cred_file, std::ios::out | std::ios::trunc);
|
||||
c << std::setw(4) << j << std::endl;
|
||||
c << j.dump(1, '\t') << std::endl;
|
||||
c.close();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user