[Bug 1405873] Re: -json output not valid when -class filter used

Vern Hart 1405873 at bugs.launchpad.net
Sat Nov 10 00:48:29 UTC 2018


I can confirm, this is still broken.

In my output, I'm missing the leading and trailing square bracket. Also,
between some stanzas there are close and open curly braces (on the same
line) without a comma in between.

Since those are the only two syntactical errors in the output I'm working with, this simple one-liner works around it:
 
(echo "["; lshw -json -C network | sed 's/} .*{/}, {/'; echo "]") | jq .

-- 
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:
  Confirmed

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