[Bug 265223] libxo json output for ps uses strings for numeric properties
Date: Thu, 14 Jul 2022 23:34:24 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265223
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 types:
{
"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=60052a11db8e729e8df92611c05135f009c01081#n1204
--
You are receiving this mail because:
You are the assignee for the bug.