mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
json: add new json_variant_is_blank_{object,array}() helpers
This commit is contained in:
parent
07737617a1
commit
e787b211a5
@ -946,6 +946,19 @@ mismatch:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool json_variant_is_blank_object(JsonVariant *v) {
|
||||
/* Returns true if the specified object is null or empty */
|
||||
return !v ||
|
||||
json_variant_is_null(v) ||
|
||||
(json_variant_is_object(v) && json_variant_elements(v) == 0);
|
||||
}
|
||||
|
||||
bool json_variant_is_blank_array(JsonVariant *v) {
|
||||
return !v ||
|
||||
json_variant_is_null(v) ||
|
||||
(json_variant_is_array(v) && json_variant_elements(v) == 0);
|
||||
}
|
||||
|
||||
JsonVariantType json_variant_type(JsonVariant *v) {
|
||||
|
||||
if (!v)
|
||||
|
@ -120,6 +120,8 @@ static inline bool json_variant_is_null(JsonVariant *v) {
|
||||
}
|
||||
|
||||
bool json_variant_is_negative(JsonVariant *v);
|
||||
bool json_variant_is_blank_object(JsonVariant *v);
|
||||
bool json_variant_is_blank_array(JsonVariant *v);
|
||||
|
||||
size_t json_variant_elements(JsonVariant *v);
|
||||
JsonVariant *json_variant_by_index(JsonVariant *v, size_t index);
|
||||
|
Loading…
Reference in New Issue
Block a user