control: fanctl query dump: Deal with arrays

The existing fanctl query_dump code was expecting the JSON it was
dealing with to be an object and not an array. When the JSON was an
array it would convert it into an object, which could change the entry
ordering.

To fix it, specifically check for the array type and use the '--name'
parameter to match on text in the array.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Id1dc1c5b3516c5ffe00484012d72464e1058ec8e
diff --git a/control/fanctl.cpp b/control/fanctl.cpp
index 3496b3c..f069d29 100644
--- a/control/fanctl.cpp
+++ b/control/fanctl.cpp
@@ -570,6 +570,20 @@
 
     const auto& section = dumpData.at(dq.section);
 
+    if (section.is_array())
+    {
+        for (const auto& entry : section)
+        {
+            if (!entry.is_string() || dq.name.empty() ||
+                (entry.get<std::string>().find(dq.name) != std::string::npos))
+            {
+                output[dq.section].push_back(entry);
+            }
+        }
+        std::cout << std::setw(4) << output << "\n";
+        return;
+    }
+
     for (const auto& [key1, values1] : section.items())
     {
         if (dq.name.empty() || (key1.find(dq.name) != std::string::npos))