mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
util: json: Add accessor for geting a VIR_JSON_TYPE_NUMBER as string
Sometimes it's desired to get a JSON number as string. Add a helper. This will help in cases where we'd want to convert the internal type from string to something else. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
0f0ad1116c
commit
1cbe6aa220
@ -2038,6 +2038,7 @@ virJSONValueGetBoolean;
|
||||
virJSONValueGetNumberDouble;
|
||||
virJSONValueGetNumberInt;
|
||||
virJSONValueGetNumberLong;
|
||||
virJSONValueGetNumberString;
|
||||
virJSONValueGetNumberUint;
|
||||
virJSONValueGetNumberUlong;
|
||||
virJSONValueGetString;
|
||||
|
@ -1043,6 +1043,16 @@ virJSONValueGetString(virJSONValuePtr string)
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
virJSONValueGetNumberString(virJSONValuePtr number)
|
||||
{
|
||||
if (number->type != VIR_JSON_TYPE_NUMBER)
|
||||
return NULL;
|
||||
|
||||
return number->data.number;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virJSONValueGetNumberInt(virJSONValuePtr number,
|
||||
int *value)
|
||||
|
@ -134,6 +134,7 @@ const char *virJSONValueObjectGetKey(virJSONValuePtr object, unsigned int n);
|
||||
virJSONValuePtr virJSONValueObjectGetValue(virJSONValuePtr object, unsigned int n);
|
||||
|
||||
const char *virJSONValueGetString(virJSONValuePtr object);
|
||||
const char *virJSONValueGetNumberString(virJSONValuePtr number);
|
||||
int virJSONValueGetNumberInt(virJSONValuePtr object, int *value);
|
||||
int virJSONValueGetNumberUint(virJSONValuePtr object, unsigned int *value);
|
||||
int virJSONValueGetNumberLong(virJSONValuePtr object, long long *value);
|
||||
|
Loading…
Reference in New Issue
Block a user