Remove generateJson function from the DocumentationGenerator and move sortJson function to json_helper

This commit is contained in:
Ylva Selling
2023-04-25 16:32:04 -04:00
parent b8b2867a20
commit 948fdd024b
15 changed files with 51 additions and 39 deletions

View File

@@ -84,4 +84,29 @@ std::string formatJsonNumber(double d) {
return std::to_string(d);
}
void sortJson(nlohmann::json& json, const std::string& key) {
std::sort(
json.begin(),
json.end(),
[&key](const nlohmann::json& lhs, const nlohmann::json& rhs) {
std::string lhsString = lhs[key];
std::string rhsString = rhs[key];
std::transform(
lhsString.begin(),
lhsString.end(),
lhsString.begin(),
[](unsigned char c) { return std::tolower(c); }
);
std::transform(
rhsString.begin(),
rhsString.end(),
rhsString.begin(),
[](unsigned char c) { return std::tolower(c); }
);
return rhsString > lhsString;
}
);
}
} // namespace openspace