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

Jeff Silverman jeffsilverm at gmail.com
Mon Aug 27 07:26:34 UTC 2018


Still broken:

$ sudo lshw -json -C network | jq .
{                           
  "id": "network",
  "class": "network",
...
    "100bt-fd": "100Mbit/s (full duplex)",
    "1000bt-fd": "1Gbit/s (full duplex)",
    "autonegotiation": "Auto-negotiation"
  }
}
parse error: Expected value before ',' at line 48, column 4
$ 

Note that there is no leading [


$ sudo lshw -json -C network | head -5
                                                                                                                                              {
    "id"; : "network",
    "class"; : "network",
    "claimed" : true,
    "handle" : "PCI:0000:00:19.0",

But there is a comma at line 48.  Why is jq failing there?  Because
there is no [.  If I insert one, then the problem disappears.

$ sudo lshw -json -C network | head -52 | tail -6
    }                       
  },
                                                            {
    "id"; : "network",
    "class" : "network",
    "claimed" : true,

Note that there is no ] at the end of the file, which also causes jq to
fail.

$ sudo lshw -json -C network | tail -6
    },                      
    "capabilities" : {
    "ethernet" : true,
    "physical" : "Physical interface"
    }
  }
$

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