From f347756661ff81ff859ec15c16a0348ef5165bed Mon Sep 17 00:00:00 2001 From: Mikhail Zhvakin Date: Tue, 25 Jul 2023 17:03:32 +0300 Subject: DBus REST: Fix array and dict handling The bmcweb DBus REST API cannot currently handle array or dictionary data types correctly. This commit is meant to fix that. Tested: get/set DBus attributes (consisting of array and/or dictionary) via bmcweb DBus REST API. Change-Id: I9694cb888375c90d7a8fb1a10e53bdb5c0bce3bb Signed-off-by: Mikhail Zhvakin --- include/openbmc_dbus_rest.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp index e0c16d9e8f..6bd3920587 100644 --- a/include/openbmc_dbus_rest.hpp +++ b/include/openbmc_dbus_rest.hpp @@ -863,7 +863,7 @@ inline int convertJsonToDbus(sd_bus_message* m, const std::string& argType, } else if (argCode.starts_with("(") && argCode.ends_with(")")) { - std::string containedType = argCode.substr(1, argCode.size() - 1); + std::string containedType = argCode.substr(1, argCode.size() - 2); r = sd_bus_message_open_container(m, SD_BUS_TYPE_STRUCT, containedType.c_str()); if (r < 0) @@ -872,7 +872,7 @@ inline int convertJsonToDbus(sd_bus_message* m, const std::string& argType, } nlohmann::json::const_iterator it = j->begin(); - for (const std::string& argCode2 : dbusArgSplit(argType)) + for (const std::string& argCode2 : dbusArgSplit(containedType)) { if (it == j->end()) { @@ -889,7 +889,7 @@ inline int convertJsonToDbus(sd_bus_message* m, const std::string& argType, } else if (argCode.starts_with("{") && argCode.ends_with("}")) { - std::string containedType = argCode.substr(1, argCode.size() - 1); + std::string containedType = argCode.substr(1, argCode.size() - 2); r = sd_bus_message_open_container(m, SD_BUS_TYPE_DICT_ENTRY, containedType.c_str()); if (r < 0) -- cgit v1.2.3