bootctl: make --json output normal json
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 15 Nov 2022 14:00:57 +0000 (15:00 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 1 Dec 2022 17:00:49 +0000 (18:00 +0100)
commitb570204a97bccfbfce8fc4ffa65306f8a06fe16e
tree9f629793190bb04507077ff3cd9dcbccc782b57e
parent4cb8a25b04f7a5f57f98dc08db155b8d071a51f5
bootctl: make --json output normal json

We would output a sequence of concatenated JSON strings. 'jq' accepts such
output without fuss, and can even automatically build an array with --slurp/-s.
Nevertheless, parsing this format is more effort for the reader, since it's not
"standard JSON". E.g. Python's json module cannot do this out-of-the-box, but
needs some loop with json.JSONDecoder.raw_decode() and then collecting the
objects into an array. Such streaming output make sense in case of logs, where
we stream the output and it has no predefined length. But here we expect at
most a few dozen entries, so it's nicer to write normal JSON that is trivial to
parse.

I'm treating this is a bugfix and not attempting to provide compatibility
backwards. I don't think the previous format was seeing much use, and it's
trivial to adapt to the new one.
src/shared/bootspec.c