Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jul 2022 23:34:24 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 265223] libxo json output for ps uses strings for numeric properties
Message-ID:  <bug-265223-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D265223

            Bug ID: 265223
           Summary: libxo json output for ps uses strings for numeric
                    properties
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: wes@wezm.net

It seems that all the properties that are collected for output in `ps` are
stringified in format_output[1]. As a result values that are numeric end up=
 as
strings in the libxo json output. E.g.

$ ps --libxo json,pretty -o pid,command,pcpu
{
  "process-information": {
    "process": [
      {
        "pid": "30811",
        "command": "-sh (sh)",
        "percent-cpu": "0.0"
      },
      {
        "pid": "30816",
        "command": "ps --libxo json,",
        "percent-cpu": "0.0"
      },
      {
        "pid": "16796",
        "command": "./mqttd",
        "percent-cpu": "0.0"
      }
    ]
  }
}

The expected behaviour in this example would be for `pid` and `percent-cpu`=
 to
be JSON numbers (although this issue is not limited to just these fields). =
I.e.

      {
        "pid": 16796,
        "command": "./mqttd",
        "percent-cpu": 0.0
      }

For comparison I note that the libxo output of `df` does use the correct ty=
pes:

      {
        "name": "zroot/usr/src",
        "total-blocks": 24195196,
        "used-blocks": 96,
        "available-blocks": 24195100,
        "used-percent": 0,
        "mounted-on": "/usr/src"
      },

[1]:
https://cgit.freebsd.org/src/tree/bin/ps/ps.c?id=3D60052a11db8e729e8df92611=
c05135f009c01081#n1204

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-265223-227>