summaryrefslogtreecommitdiff
path: root/include/image_upload.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-03-15 20:44:42 +0300
committerEd Tanous <edtanous@google.com>2022-05-13 01:08:18 +0300
commit1476687deb1697d865b20458a0097c9ab5fd44e2 (patch)
tree6964ba82c382d03522f7a413a61ae1164b8e242e /include/image_upload.hpp
parent1656b296313d75b172dcdbe5f37ff1d1b54800dc (diff)
downloadbmcweb-1476687deb1697d865b20458a0097c9ab5fd44e2.tar.xz
Remove brace initialization of json objects
Brace initialization of json objects, while quite interesting from an academic sense, are very difficult for people to grok, and lead to inconsistencies. This patchset aims to remove a majority of them in lieu of operator[]. Interestingly, this saves about 1% of the binary size of bmcweb. This also has an added benefit that as a design pattern, we're never constructing a new object, then moving it into place, we're always adding to the existing object, which in the future _could_ make things like OEM schemas or properties easier, as there's no case where we're completely replacing the response object. Tested: Ran redfish service validator. No new failures. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iae409b0a40ddd3ae6112cb2d52c6f6ab388595fe
Diffstat (limited to 'include/image_upload.hpp')
-rw-r--r--include/image_upload.hpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/include/image_upload.hpp b/include/image_upload.hpp
index 330ea9c379..aefb27e3a8 100644
--- a/include/image_upload.hpp
+++ b/include/image_upload.hpp
@@ -51,12 +51,10 @@ inline void
}
asyncResp->res.result(boost::beast::http::status::bad_request);
- asyncResp->res.jsonValue = {
- {"data",
- {{"description",
- "Version already exists or failed to be extracted"}}},
- {"message", "400 Bad Request"},
- {"status", "error"}};
+ asyncResp->res.jsonValue["data"]["description"] =
+ "Version already exists or failed to be extracted";
+ asyncResp->res.jsonValue["message"] = "400 Bad Request";
+ asyncResp->res.jsonValue["status"] = "error";
};
std::function<void(sdbusplus::message::message&)> callback =
@@ -80,8 +78,9 @@ inline void
leaf = path.str;
}
- asyncResp->res.jsonValue = {
- {"data", leaf}, {"message", "200 OK"}, {"status", "ok"}};
+ asyncResp->res.jsonValue["data"] = leaf;
+ asyncResp->res.jsonValue["message"] = "200 OK";
+ asyncResp->res.jsonValue["status"] = "ok";
BMCWEB_LOG_DEBUG << "ending response";
fwUpdateMatcher = nullptr;
}