[Bug 1405873] Re: -json output not valid when -class filter used
Waldek M.
1405873 at bugs.launchpad.net
Tue Jun 27 08:29:03 UTC 2023
Personally, I'm still seeing an issue related to commas in json output
on Bionic.
$ apt show lshw 2>/dev/null | head -n2
Package: lshw
Version: 02.18-0.1ubuntu6.18.04.2
$ sudo lshw -C display -json | jq
{
"id": "display",
"class": "display",
"claimed": true,
"handle": "PCI:0000:00:0f.0",
"description": "VGA compatible controller",
"product": "SVGA II Adapter",
"vendor": "VMware",
"physid": "f",
"businfo": "pci at 0000:00:0f.0",
"version": "00",
"width": 32,
"clock": 33000000,
"configuration": {
"driver": "vmwgfx",
"latency": "64"
},
"capabilities": {
"vga_controller": true,
"bus_master": "bus mastering",
"cap_list": "PCI capabilities listing",
"rom": "extension ROM"
}
}
parse error: Expected value before ',' at line 24, column 4
===
It's basically a spurious comma at the end ouf the output
$ sudo lshw -C display -json
# ...[several spurious newlines] {
"id" : "display",
"class" : "display",
"claimed" : true,
"handle" : "PCI:0000:00:0f.0",
"description" : "VGA compatible controller",
"product" : "SVGA II Adapter",
"vendor" : "VMware",
"physid" : "f",
"businfo" : "pci at 0000:00:0f.0",
"version" : "00",
"width" : 32,
"clock" : 33000000,
"configuration" : {
"driver" : "vmwgfx",
"latency" : "64"
},
"capabilities" : {
"vga_controller" : true,
"bus_master" : "bus mastering",
"cap_list" : "PCI capabilities listing",
"rom" : "extension ROM"
}
},
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to lshw in Ubuntu.
https://bugs.launchpad.net/bugs/1405873
Title:
-json output not valid when -class filter used
Status in lshw package in Ubuntu:
Fix Released
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
*-multimedia:0
*-usb:0
*-communication
*-network
*-usb:1
*-multimedia:1
*-pci:1
*-pci:2
*-network
*-pci:3
*-usb
*-usb:2
*-isa
*-storage
*-serial UNCLAIMED
*-scsi:0
*-disk
*-scsi:1
*-disk
*-volume:0
*-volume:1
*-volume:2
*-scsi:2
*-disk
*-volume:0
*-volume:1
*-volume:2
*-scsi:3
*-disk
*-scsi:4
*-disk
*-scsi:5
*-disk
*-volume:0
*-volume:1
*-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
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lshw/+bug/1405873/+subscriptions
More information about the foundations-bugs
mailing list