mirror of
https://github.com/systemd/systemd.git
synced 2024-11-05 23:51:28 +03:00
json: add json_variant_set_field_integer() and json_variant_set_field_boolean() helpers
This commit is contained in:
parent
faca141c5f
commit
a832b08e6e
@ -1905,6 +1905,17 @@ int json_variant_set_field_string(JsonVariant **v, const char *field, const char
|
||||
return json_variant_set_field(v, field, m);
|
||||
}
|
||||
|
||||
int json_variant_set_field_integer(JsonVariant **v, const char *field, intmax_t i) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *m = NULL;
|
||||
int r;
|
||||
|
||||
r = json_variant_new_integer(&m, i);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return json_variant_set_field(v, field, m);
|
||||
}
|
||||
|
||||
int json_variant_set_field_unsigned(JsonVariant **v, const char *field, uintmax_t u) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *m = NULL;
|
||||
int r;
|
||||
@ -1916,6 +1927,17 @@ int json_variant_set_field_unsigned(JsonVariant **v, const char *field, uintmax_
|
||||
return json_variant_set_field(v, field, m);
|
||||
}
|
||||
|
||||
int json_variant_set_field_boolean(JsonVariant **v, const char *field, bool b) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *m = NULL;
|
||||
int r;
|
||||
|
||||
r = json_variant_new_boolean(&m, b);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return json_variant_set_field(v, field, m);
|
||||
}
|
||||
|
||||
int json_variant_merge(JsonVariant **v, JsonVariant *m) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *w = NULL;
|
||||
_cleanup_free_ JsonVariant **array = NULL;
|
||||
|
@ -178,7 +178,9 @@ int json_variant_filter(JsonVariant **v, char **to_remove);
|
||||
|
||||
int json_variant_set_field(JsonVariant **v, const char *field, JsonVariant *value);
|
||||
int json_variant_set_field_string(JsonVariant **v, const char *field, const char *value);
|
||||
int json_variant_set_field_integer(JsonVariant **v, const char *field, intmax_t value);
|
||||
int json_variant_set_field_unsigned(JsonVariant **v, const char *field, uintmax_t value);
|
||||
int json_variant_set_field_boolean(JsonVariant **v, const char *field, bool b);
|
||||
|
||||
int json_variant_append_array(JsonVariant **v, JsonVariant *element);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user