Add loadJSONFromFile() in utility
It provides a util function to load json from a file.
Tested: Manually verify the function works.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I4dc946663e0ce1bf511de90b27b7aa425a338543
diff --git a/utility.hpp b/utility.hpp
index 0f008e3..df66852 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <nlohmann/json.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
@@ -104,6 +105,15 @@
bus.call_noreply(method);
}
+/**
+ * Load json from a file
+ *
+ * @param[in] path - The path of the json file
+ *
+ * @return The nlohmann::json object
+ */
+nlohmann::json loadJSONFromFile(const char* path);
+
} // namespace util
} // namespace power
} // namespace witherspoon