summaryrefslogtreecommitdiff
path: root/repo/lshw/2b1c730b493d647bbab4854713571458e82a81e7.patch
blob: 57dccb5ffb9588b2ebd4b3f60995ac14d2b84ad5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 2b1c730b493d647bbab4854713571458e82a81e7 Mon Sep 17 00:00:00 2001
From: Lyonel Vincent <lyonel@ezix.org>
Date: Tue, 26 May 2020 01:00:37 +0200
Subject: [PATCH] JSON output clean-up (list/object)

---
 src/core/hw.cc | 5 ++---
 src/lshw.cc    | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/core/hw.cc b/src/core/hw.cc
index aca424c..ab345fe 100644
--- a/src/core/hw.cc
+++ b/src/core/hw.cc
@@ -1400,7 +1400,7 @@ string hwNode::asJSON(unsigned level)
   config = getConfigKeys();
   resources = getResources("\" value=\"");
 
-  if (level == 0)
+  if (::enabled("output:list") && level == 0)
   {
     out << "[" << endl;
   }
@@ -1665,9 +1665,8 @@ string hwNode::asJSON(unsigned level)
     out << "}";
   }
 
-  if (level == 0)
+  if (::enabled("output:list") && level == 0)
   {
-    out.seekp(-2, std::ios_base::end);
     out << endl << "]" << endl;
   }
 
diff --git a/src/lshw.cc b/src/lshw.cc
index 219a008..571b1c3 100644
--- a/src/lshw.cc
+++ b/src/lshw.cc
@@ -84,6 +84,7 @@ char **argv)
 
   disable("isapnp");
 
+  disable("output:list");
   disable("output:json");
   disable("output:db");
   disable("output:xml");