45inline void RequireKnownKeys(
const nlohmann::json& node, std::initializer_list<const char*> known,
const std::string& what)
47 if (!node.is_object())
48 throw std::runtime_error(what +
" must be a JSON object");
49 for (
const auto& entry : node.items()) {
50 if (entry.key().starts_with(
'_'))
52 const bool isKnown = std::any_of(known.begin(), known.end(), [&](
const char* key) { return entry.key() == key; });
56 for (
const char* key : known)
57 expected += std::string(expected.empty() ?
"" :
", ") +
"'" + key +
"'";
58 throw std::runtime_error(
"unknown key '" + entry.key() +
"' in " + what +
"; expected " + expected);
void RequireKnownKeys(const nlohmann::json &node, std::initializer_list< const char * > known, const std::string &what)
Definition JsonReading.h:45