diff --git a/utils.cpp b/utils.cpp
index b9d07e4..69fbe6e 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -3,12 +3,19 @@
 #include "utils.hpp"
 
 #include "defines.hpp"
+#include "vpd_exceptions.hpp"
 
+#include <fstream>
+#include <iomanip>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/server.hpp>
+#include <sstream>
+#include <vector>
 #include <xyz/openbmc_project/Common/error.hpp>
 
+using json = nlohmann::json;
+
 namespace openpower
 {
 namespace vpd
@@ -17,7 +24,8 @@
 using namespace inventory;
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-
+using namespace record;
+using namespace openpower::vpd::exceptions;
 namespace inventory
 {
 
@@ -230,5 +238,113 @@
             "Error in invoking D-Bus logging create interface to register PEL");
     }
 }
+
+inventory::VPDfilepath getVpdFilePath(const string& jsonFile,
+                                      const std::string& ObjPath)
+{
+    ifstream inventoryJson(jsonFile);
+    const auto& jsonObject = json::parse(inventoryJson);
+    inventory::VPDfilepath filePath{};
+
+    if (jsonObject.find("frus") == jsonObject.end())
+    {
+        throw(VpdJsonException(
+            "Invalid JSON structure - frus{} object not found in ", jsonFile));
+    }
+
+    const nlohmann::json& groupFRUS =
+        jsonObject["frus"].get_ref<const nlohmann::json::object_t&>();
+    for (const auto& itemFRUS : groupFRUS.items())
+    {
+        const std::vector<nlohmann::json>& groupEEPROM =
+            itemFRUS.value().get_ref<const nlohmann::json::array_t&>();
+        for (const auto& itemEEPROM : groupEEPROM)
+        {
+            if (itemEEPROM["inventoryPath"]
+                    .get_ref<const nlohmann::json::string_t&>() == ObjPath)
+            {
+                filePath = itemFRUS.key();
+                return filePath;
+            }
+        }
+    }
+
+    return filePath;
+}
+
+bool isPathInJson(const std::string& eepromPath)
+{
+    bool present = false;
+    ifstream inventoryJson(INVENTORY_JSON_SYM_LINK);
+
+    try
+    {
+        auto js = json::parse(inventoryJson);
+        if (js.find("frus") == js.end())
+        {
+            throw(VpdJsonException(
+                "Invalid JSON structure - frus{} object not found in ",
+                INVENTORY_JSON_SYM_LINK));
+        }
+        json fruJson = js["frus"];
+
+        if (fruJson.find(eepromPath) != fruJson.end())
+        {
+            present = true;
+        }
+    }
+    catch (json::parse_error& ex)
+    {
+        throw(VpdJsonException("Json Parsing failed", INVENTORY_JSON_SYM_LINK));
+    }
+    return present;
+}
+
+bool isRecKwInDbusJson(const std::string& recordName,
+                       const std::string& keyword)
+{
+    ifstream propertyJson(DBUS_PROP_JSON);
+    json dbusProperty;
+    bool present = false;
+
+    if (propertyJson.is_open())
+    {
+        try
+        {
+            auto dbusPropertyJson = json::parse(propertyJson);
+            if (dbusPropertyJson.find("dbusProperties") ==
+                dbusPropertyJson.end())
+            {
+                throw(VpdJsonException("dbusProperties{} object not found in "
+                                       "DbusProperties json : ",
+                                       DBUS_PROP_JSON));
+            }
+
+            dbusProperty = dbusPropertyJson["dbusProperties"];
+            if (dbusProperty.contains(recordName))
+            {
+                const vector<string>& kwdsToPublish = dbusProperty[recordName];
+                if (find(kwdsToPublish.begin(), kwdsToPublish.end(), keyword) !=
+                    kwdsToPublish.end()) // present
+                {
+                    present = true;
+                }
+            }
+        }
+        catch (json::parse_error& ex)
+        {
+            throw(VpdJsonException("Json Parsing failed", DBUS_PROP_JSON));
+        }
+    }
+    else
+    {
+        // If dbus properties json is not available, we assume the given
+        // record-keyword is part of dbus-properties json. So setting the bool
+        // variable to true.
+        present = true;
+    }
+    return present;
+}
+
 } // namespace vpd
 } // namespace openpower
