]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-bus: handle non-string keys in dictionaries in JSON dump
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 12 May 2026 15:09:41 +0000 (17:09 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 12 May 2026 22:50:32 +0000 (07:50 +0900)
commit7cecff8c9949d4bfd85b06c6dba3691e82ec86d4
treef12ca7b6a9a60d288239fad2d3d8e4c5c73171c6
parent304899fa57d0ad5ee57a8c7ee854ad74affe2eda
sd-bus: handle non-string keys in dictionaries in JSON dump

JSON only supports string keys in objects, but D-Bus specification is a
bit more lenient and allows dict entries to have any basic type as key.
Let's stringify allowed non-string keys so that we can represent them as
JSON objects.

Relevant snippet from the D-Bus specification:

  A DICT_ENTRY works exactly like a struct, but rather than parentheses
  it uses curly braces, and it has more restrictions. The restrictions
  are: it occurs only as an array element type; it has exactly two
  single complete types inside the curly braces; the first single
  complete type (the "key") must be a basic type rather than a container
  type. Implementations must not accept dict entries outside of arrays,
  must not accept dict entries with zero, one, or more than two fields,
  and must not accept dict entries with non-basic-typed keys. A dict
  entry is always a key-value pair.

Resolves: #32904
src/libsystemd/sd-bus/bus-dump-json.c
test/units/TEST-74-AUX-UTILS.busctl.sh