ppforest2
v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
JsonValidation.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <initializer_list>
4
#include <set>
5
#include <stdexcept>
6
#include <string>
7
8
#include <nlohmann/json.hpp>
9
10
namespace
ppforest2
{
19
inline
void
20
validate_json_keys
(nlohmann::json
const
& j, std::string
const
& context, std::initializer_list<std::string> allowed) {
21
std::set<std::string> allowed_set(allowed);
22
23
for
(
auto
it = j.begin(); it != j.end(); ++it) {
24
if
(allowed_set.find(it.key()) == allowed_set.end()) {
25
throw
std::runtime_error(
"Unknown "
+ context +
" parameter: "
+ it.key());
26
}
27
}
28
}
29
}
ppforest2
Definition
Benchmark.hpp:22
ppforest2::validate_json_keys
void validate_json_keys(nlohmann::json const &j, std::string const &context, std::initializer_list< std::string > allowed)
Validate that a JSON object contains only expected keys.
Definition
JsonValidation.hpp:20
core
src
utils
JsonValidation.hpp
Generated by
1.13.2