mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +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;
|
virJSONValueGetNumberDouble;
|
||||||
virJSONValueGetNumberInt;
|
virJSONValueGetNumberInt;
|
||||||
virJSONValueGetNumberLong;
|
virJSONValueGetNumberLong;
|
||||||
|
virJSONValueGetNumberString;
|
||||||
virJSONValueGetNumberUint;
|
virJSONValueGetNumberUint;
|
||||||
virJSONValueGetNumberUlong;
|
virJSONValueGetNumberUlong;
|
||||||
virJSONValueGetString;
|
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
|
int
|
||||||
virJSONValueGetNumberInt(virJSONValuePtr number,
|
virJSONValueGetNumberInt(virJSONValuePtr number,
|
||||||
int *value)
|
int *value)
|
||||||
|
@ -134,6 +134,7 @@ const char *virJSONValueObjectGetKey(virJSONValuePtr object, unsigned int n);
|
|||||||
virJSONValuePtr virJSONValueObjectGetValue(virJSONValuePtr object, unsigned int n);
|
virJSONValuePtr virJSONValueObjectGetValue(virJSONValuePtr object, unsigned int n);
|
||||||
|
|
||||||
const char *virJSONValueGetString(virJSONValuePtr object);
|
const char *virJSONValueGetString(virJSONValuePtr object);
|
||||||
|
const char *virJSONValueGetNumberString(virJSONValuePtr number);
|
||||||
int virJSONValueGetNumberInt(virJSONValuePtr object, int *value);
|
int virJSONValueGetNumberInt(virJSONValuePtr object, int *value);
|
||||||
int virJSONValueGetNumberUint(virJSONValuePtr object, unsigned int *value);
|
int virJSONValueGetNumberUint(virJSONValuePtr object, unsigned int *value);
|
||||||
int virJSONValueGetNumberLong(virJSONValuePtr object, long long *value);
|
int virJSONValueGetNumberLong(virJSONValuePtr object, long long *value);
|
||||||
|
Loading…
Reference in New Issue
Block a user