json: extend JsonDispatch flags with nullable and refuse-null flags
authorLennart Poettering <lennart@poettering.net>
Wed, 8 May 2024 07:42:12 +0000 (09:42 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 15 Jun 2024 09:58:02 +0000 (10:58 +0100)
commit3d6c2c918bdf59eab8edd6eda4e7ffd4efb09d33
tree8aa4bb94cb9bac14ecfeecb92fc1406e2e8328ed
parent26279199cfb5dab594041192549c04e1164d3971
json: extend JsonDispatch flags with nullable and refuse-null flags

currently when dispatching json objects into C structs we either insist
on the field type or we don't. Let's extend this model a bit: depending
on two new fields either allow or refuse null types in addition to the
specified type.

This is useful for example when dispatch enums as this allows us
explicitly refuse null in various scenarios where we allow multiple
types.
src/libsystemd/sd-json/sd-json.c
src/systemd/sd-json.h
src/test/test-json.c