20 #include "gateway/dbus/dbusgatewayparser.h" 21 #include "gateway/gatewayparsererror.h" 25 bool DBusGatewayParser::parseDBusConfig(
const json_t *element,
29 log_debug() <<
"Parsing element for " << key;
30 json_t *configExists = json_object_get(element, key);
31 if (
nullptr == configExists) {
33 log_warning() << key <<
" was not found in config.";
37 if (!json_is_array(configExists)) {
38 throwWithLog(logging::StringBuilder() <<
"Value for " << key <<
" is not an array");
41 for (
unsigned int i = 0; i < json_array_size(configExists); i++) {
42 json_t *child = json_array_get(configExists, i);
43 if (!json_is_object(child)) {
44 throwWithLog(
"JSON array element is not an object!");
46 json_array_append(config, json_deep_copy(child));
53 void DBusGatewayParser::throwWithLog(std::string message)
55 log_error() << message;
56 throw GatewayParserError(message);
Developers guide to adding a config item: