]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/home/homectl.c
json: rename json_append() → json_variant_merge_objectb()
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Aug 2023 07:41:48 +0000 (09:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 24 Aug 2023 11:20:39 +0000 (13:20 +0200)
commite931768eb4687ac5a456987fe5bea4ec87225637
tree6ee676773c99f6fd5158f2ef5543f8fdcc5203e5
parentc91f581c4706af36f87f911067c4569c0ff08676
json: rename json_append() → json_variant_merge_objectb()

json_append() is a useful wrapper around json_variant_merge(). However,
I think the naming sould be cleaned up a bit of both functions.

I thinker "merge" is the better word than "append", since it does
decidedly more than just append: it replaces existing fields of the same
name, hence "merge" sounds more appropriate. This is as opposed to the
similar operations for arrays, where no such override logic is applied
and we really just append, hence those functions are called "append"
already.

To make clearer that "merge" is about objects, and "append" about
arrays, also include "object" in the name.

Also, include "json_variant" in the name, like we do for almost all
other functions in the JSON API that take a JSON object as primary
input, and hence are kinda object methods.

Finally, let's follow the logic that helpers that combine json_build()
with some other operation get suffixed with "b" like we already have in
some cases.

Hence:

json_variant_merge() → json_variant_merge_object()
       json_append() → json_variant_merge_objectb()

This mirrors nicely the existing:
                       json_variant_append_array()
                       json_vairant_append_arrayb()

This also drops the variant of json_append() that takes a va_arg
parameter (i.e. json_appendv()). We have no user of that so far, and
given the nature as a helper function only I don#t see that happening,
and if it happens after all it's trivial to bring back.
src/fuzz/fuzz-json.c
src/home/homectl.c
src/home/homed-home.c
src/home/user-record-util.c
src/network/networkd-json.c
src/shared/bootspec.c
src/shared/elf-util.c
src/shared/json.c
src/shared/json.h
src/shared/userdb-dropin.c
src/test/test-json.c