Fix unused variable warning in LDAP

It's not clear how this came to be the way it is, but tidy now warns
that this variable is unused (which it is).

Refactor the LDAP code to not use the variable, and to use concrete
object_t and array_t

Tested: Redfish service validator passes.

Change-Id: I0c106d10594a396d506bf9865cb29d4a10a372a1
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index ab9048a..23f1616 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -321,27 +321,32 @@
                                 const LDAPConfigData& confData,
                                 const std::string& ldapType)
 {
-    std::string service = (ldapType == "LDAP") ? "LDAPService"
-                                               : "ActiveDirectoryService";
-
-    nlohmann::json& ldap = jsonResponse[ldapType];
-
+    nlohmann::json::object_t ldap;
     ldap["ServiceEnabled"] = confData.serviceEnabled;
-    ldap["ServiceAddresses"] = nlohmann::json::array({confData.uri});
-    ldap["Authentication"]["AuthenticationType"] =
+    nlohmann::json::array_t serviceAddresses;
+    serviceAddresses.emplace_back(confData.uri);
+    ldap["ServiceAddresses"] = std::move(serviceAddresses);
+
+    nlohmann::json::object_t authentication;
+    authentication["AuthenticationType"] =
         account_service::AuthenticationTypes::UsernameAndPassword;
-    ldap["Authentication"]["Username"] = confData.bindDN;
-    ldap["Authentication"]["Password"] = nullptr;
+    authentication["Username"] = confData.bindDN;
+    authentication["Password"] = nullptr;
+    ldap["Authentication"] = std::move(authentication);
 
-    ldap["LDAPService"]["SearchSettings"]["BaseDistinguishedNames"] =
-        nlohmann::json::array({confData.baseDN});
-    ldap["LDAPService"]["SearchSettings"]["UsernameAttribute"] =
-        confData.userNameAttribute;
-    ldap["LDAPService"]["SearchSettings"]["GroupsAttribute"] =
-        confData.groupAttribute;
+    nlohmann::json::object_t ldapService;
+    nlohmann::json::object_t searchSettings;
+    nlohmann::json::array_t baseDistinguishedNames;
+    baseDistinguishedNames.emplace_back(confData.baseDN);
 
-    nlohmann::json& roleMapArray = ldap["RemoteRoleMapping"];
-    roleMapArray = nlohmann::json::array();
+    searchSettings["BaseDistinguishedNames"] =
+        std::move(baseDistinguishedNames);
+    searchSettings["UsernameAttribute"] = confData.userNameAttribute;
+    searchSettings["GroupsAttribute"] = confData.groupAttribute;
+    ldapService["SearchSettings"] = std::move(searchSettings);
+    ldap["LDAPService"] = std::move(ldapService);
+
+    nlohmann::json::array_t roleMapArray;
     for (const auto& obj : confData.groupRoleList)
     {
         BMCWEB_LOG_DEBUG("Pushing the data groupName={}", obj.second.groupName);
@@ -351,6 +356,10 @@
         remoteGroup["LocalRole"] = getRoleIdFromPrivilege(obj.second.privilege);
         roleMapArray.emplace_back(std::move(remoteGroup));
     }
+
+    ldap["RemoteRoleMapping"] = std::move(roleMapArray);
+
+    jsonResponse[ldapType].update(ldap);
 }
 
 /**