Go to the documentation of this file.
22 #ifndef JSON_SCHEMA_UTILS_H
23 #define JSON_SCHEMA_UTILS_H
25 #include "nrp_general_library/config/cmake_constants.h"
27 #include "nlohmann/json-schema.hpp"
32 using nlohmann::json_schema::json_validator;
33 using nlohmann::json_uri;
63 template <
typename VALUE_T>
64 static void setDefault(
nlohmann::json &instance,
const std::string key,
const VALUE_T new_value) {
66 if(!instance.contains(key))
67 instance[key] = new_value;
84 #endif // JSON_SCHEMA_UTILS_H
std::shared_ptr< const nlohmann::json > jsonConstSharedPtr
Definition: json_schema_utils.h:36
void validateJson(nlohmann::json &instance, std::string schema_path, bool addPatch)
Validates a json object using a given json schema.
Definition: json_schema_utils.cpp:65
Definition: json_schema_utils.cpp:24
std::shared_ptr< nlohmann::json > jsonSharedPtr
Definition: json_schema_utils.h:35
void jsonSchemaLoader(const json_uri &uri, json &schema)
Loads schema from json file given its uri. To be passed to a nlohmann::json_schema::json_validator co...
Definition: json_schema_utils.cpp:49
nlohmann::json parseJSONFile(const std::string &fileName)
Parse a JSON File and return it's values.
Definition: json_schema_utils.cpp:26
nlohmann::json json
Definition: engine_json_server.cpp:31