提交 1cbe6aa2 编写于 作者: P Peter Krempa

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: NPeter Krempa <pkrempa@redhat.com>
上级 0f0ad111
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册