json: permit 'null' as a way to reset tri-states to default

This commit is contained in:
Lennart Poettering 2019-05-24 10:44:56 +02:00
parent aafa52ab83
commit 3dd1b600b8
1 changed files with 5 additions and 0 deletions

View File

@ -3826,6 +3826,11 @@ int json_dispatch_tristate(const char *name, JsonVariant *variant, JsonDispatchF
assert(variant);
assert(b);
if (json_variant_is_null(variant)) {
*b = -1;
return 0;
}
if (!json_variant_is_boolean(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a boolean.", strna(name));