-json output not valid when -class filter used
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lshw (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
When lshw is invoked with the -json option, a single JSON object describing the entire system is produced. Hardware components are nested within the JSON object structure. When the -class filter option is used with -json, one would expect an array of JSON objects, each representing one of the matching hardware components. Instead, the output appears to simply exclude the non-relevant parts of the original JSON object, keeping the parts of the structure that match the filter. The result of which is not a valid JSON object, which is sometimes missing required commas and is always missing the enclosing array brackets.
Examples from two machines with varying hardware layouts are attached (with additional -sanitze option used). Machine 1 with the 'disk' class is the most incorrect.
Machine 1
sudo lshw -version = B.02.16
sudo dpkg -s lshw | grep Version = Version: 02.16-2
lsb_release -rd = Ubuntu 13.10
sudo lshw | grep '*-'
*-core
*-firmware
*-memory:0 UNCLAIMED
*-bank UNCLAIMED
*-memory:1
*-bank
*-cache:0
*-cache:1
*-cache:2
*-cpu
*-memory:2 UNCLAIMED
*-memory:3 UNCLAIMED
*-pci
*-pci:0
*-display
*-usb:0
*-network
*-usb:1
*-pci:1
*-pci:2
*-pci:3
*-usb
*-usb:2
*-isa
*-storage
*-serial UNCLAIMED
*-scsi:0
*-disk
*-scsi:1
*-disk
*-scsi:2
*-disk
*-scsi:3
*-disk
*-scsi:4
*-disk
*-scsi:5
*-disk
*-power UNCLAIMED
Machine 2
sudo lshw -version = B.02.16
sudo dpkg -s lshw | grep Version = Version: 02.16-2ubuntu1.2
lsb_release -rd = Ubuntu 14.04.1 LTS
sudo lshw | grep '*-'
*-core
*-firmware:0
*-cpu:0
*-memory:0
*-bank:0
*-bank:1
*-firmware:1
*-cpu:1
*-memory:1
*-memory:2 UNCLAIMED
*-memory:3 UNCLAIMED
*-pci
*-isa
*-ide
*-bridge UNCLAIMED
*-display UNCLAIMED
*-generic
*-network
Status changed to 'Confirmed' because the bug affects multiple users.