PEL: Use ordered_json in code instead of fifo_map
JSON objects are defined as 'unordered collections' of zero or more
name/value pairs. The implementation doesn't need to preserve specific
orders of inputs objects and where it did (say in older versions)
external fifo_map header method was used. Now with built-in ordered_json
supported (nlohmann::ordered_json), the specific 'order of inputs
objects are preserved' automatically and are not jumbled up or external
header needed to preserve input objects anymore.
Signed-off-by: Sumit Kumar <sumit_kumar@in.ibm.com>
Change-Id: I9abc1220b9fbefbae412efc6ac128d797d0faa16
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index 398cfaa..e41de8c 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -22,7 +22,6 @@
#ifdef PELTOOL
#include <Python.h>
-#include <fifo_map.hpp>
#include <nlohmann/json.hpp>
#include <sstream>
#endif
@@ -42,11 +41,7 @@
constexpr size_t ccinSize = 4;
#ifdef PELTOOL
-// Use fifo_map as nlohmann::json's map. We are just ignoring the 'less'
-// compare. With this map the keys are kept in FIFO order.
-template <class K, class V, class dummy_compare, class A>
-using fifoMap = nlohmann::fifo_map<K, V, nlohmann::fifo_map_compare<K>, A>;
-using fifoJSON = nlohmann::basic_json<fifoMap>;
+using orderedJSON = nlohmann::ordered_json;
void pyDecRef(PyObject* pyObj)
{
@@ -64,9 +59,9 @@
*
* @return std::string - The JSON string
*/
-std::string prettyJSON(const fifoJSON& json)
+std::string prettyJSON(const orderedJSON& json)
{
- fifoJSON output;
+ orderedJSON output;
if (!json.is_object())
{
output["SRC Details"] = json;
@@ -187,7 +182,7 @@
const char* output = PyBytes_AS_STRING(pBytes);
try
{
- fifoJSON json = nlohmann::json::parse(output);
+ orderedJSON json = nlohmann::json::parse(output);
return prettyJSON(json);
}
catch (std::exception& e)