Refactor metadata returned by Readings property

Reading metadata is now JSON containg SensorDbusPath and SensorRedfishUri.
It is returned only if JSON metadata was provided during Report creation,
otherwise old behavior is maintained.

Additionally, json.hpp was removed as LabeledTupple is now used for
serialization and deserialization of metric and reading metadata.

Testing done:
- Unit test is passing as metric is returning proper metadata.
- Redfish get on redfish/v1/TelemetryService/MetricReports is containing
  MetricDefinition property, which utilizes SensorDbusPath metadata..
  Done on custom version of bmcweb.

Change-Id: I1b2cc4440d03e0fe45151b630f4e439839ed8589
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
diff --git a/src/metric.cpp b/src/metric.cpp
index 6734d28..9dd4e67 100644
--- a/src/metric.cpp
+++ b/src/metric.cpp
@@ -1,7 +1,7 @@
 #include "metric.hpp"
 
 #include "types/report_types.hpp"
-#include "utils/json.hpp"
+#include "utils/labeled_tuple.hpp"
 #include "utils/transform.hpp"
 
 #include <algorithm>
@@ -68,22 +68,29 @@
 
 void Metric::tryUnpackJsonMetadata()
 {
+    using MetricMetadata =
+        utils::LabeledTuple<std::tuple<std::vector<std::string>>,
+                            utils::tstring::MetricProperties>;
+
+    using ReadingMetadata =
+        utils::LabeledTuple<std::tuple<std::string, std::string>,
+                            utils::tstring::SensorDbusPath,
+                            utils::tstring::SensorRedfishUri>;
     try
     {
-        const nlohmann::json parsedMetadata = nlohmann::json::parse(metadata);
-        if (const auto metricProperties =
-                utils::readJson<std::vector<std::string>>(parsedMetadata,
-                                                          "MetricProperties"))
+        const MetricMetadata parsedMetadata =
+            nlohmann::json::parse(metadata).get<MetricMetadata>();
+
+        if (readings.size() == parsedMetadata.at_index<0>().size())
         {
-            if (readings.size() == metricProperties->size())
+            for (size_t i = 0; i < readings.size(); ++i)
             {
-                for (size_t i = 0; i < readings.size(); ++i)
-                {
-                    readings[i].metadata = (*metricProperties)[i];
-                }
+                ReadingMetadata readingMetadata{
+                    sensors[i]->id().path, parsedMetadata.at_index<0>()[i]};
+                readings[i].metadata = readingMetadata.dump();
             }
         }
     }
-    catch (const nlohmann::json::parse_error& e)
+    catch (const nlohmann::json::parse_error&)
     {}
 }