]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libsmartcols: support arrays for JSON output
authorKarel Zak <kzak@redhat.com>
Fri, 8 Jan 2021 12:12:57 +0000 (13:12 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 8 Jan 2021 12:12:57 +0000 (13:12 +0100)
commit3c7355dd63159427c959391c500fccecd0a18ba8
treee9d8151df17729fb9b8b314d6c7a19e7cea3b14b
parentf19295ad125d03a6bcc31d610de1df79a5a4b04e
libsmartcols: support arrays for JSON output

This patch add support to format multi-line cells (columns with
SCOLS_FL_WRAP) to arrays in JSON output.

For example mountpoints[] in lsblk output:

Normal output:
 $ lsblk -oNAME,FSTYPE,TYPE,MOUNTPOINTS /dev/sdc1
 NAME FSTYPE TYPE MOUNTPOINTS
 sdc1 btrfs  part /mnt/A
  /mnt/test
  /mnt/B

JSON output:
$ lsblk -J -oNAME,FSTYPE,TYPE,MOUNTPOINTS /dev/sdc1
{
   "blockdevices": [
      {
 "name": "sdc1",
 "fstype": "btrfs",
 "type": "part",
 "mountpoints": [
     "/mnt/A",
     "/mnt/test",
     "/mnt/B"
 ]
      }
   ]
}

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/jsonwrt.c
libsmartcols/src/libsmartcols.h.in
libsmartcols/src/print.c