Re: [PATCH 2/9] util: json: Add virJSONValueIsObject

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Peter Krempa <pkrempa@xxxxxxxxxx> [2017-06-27, 02:46PM +0200]:
> Allows testing whether a virJSONValue is an object.
> ---
>  src/libvirt_private.syms |  1 +
>  src/util/virjson.c       | 10 ++++++++++
>  src/util/virjson.h       |  2 ++
>  3 files changed, 13 insertions(+)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index c1e9471c5..d487b1f43 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1905,6 +1905,7 @@ virJSONValueGetString;
>  virJSONValueHashFree;
>  virJSONValueIsArray;
>  virJSONValueIsNull;
> +virJSONValueIsObject;
>  virJSONValueNewArray;
>  virJSONValueNewArrayFromBitmap;
>  virJSONValueNewBoolean;
> diff --git a/src/util/virjson.c b/src/util/virjson.c
> index b49b29b0f..efd6c3a0e 100644
> --- a/src/util/virjson.c
> +++ b/src/util/virjson.c
> @@ -905,6 +905,16 @@ virJSONValueObjectGetValue(virJSONValuePtr object,
> 
> 
>  bool
> +virJSONValueIsObject(virJSONValuePtr object)
> +{
> +    if (object)
> +        return object->type == VIR_JSON_TYPE_OBJECT;
> +    else
> +        return NULL;

s/NULL/false/

> +}
> +
> +
> +bool
>  virJSONValueIsArray(virJSONValuePtr array)
>  {
>      return array->type == VIR_JSON_TYPE_ARRAY;
> diff --git a/src/util/virjson.h b/src/util/virjson.h
> index 14b74c061..c9d9752de 100644
> --- a/src/util/virjson.h
> +++ b/src/util/virjson.h
> @@ -114,6 +114,8 @@ virJSONValuePtr virJSONValueObjectGet(virJSONValuePtr object, const char *key);
>  virJSONValuePtr virJSONValueObjectGetByType(virJSONValuePtr object,
>                                              const char *key, virJSONType type);
> 
> +bool virJSONValueIsObject(virJSONValuePtr object);
> +
>  bool virJSONValueIsArray(virJSONValuePtr array);
>  ssize_t virJSONValueArraySize(const virJSONValue *array);
>  virJSONValuePtr virJSONValueArrayGet(virJSONValuePtr object, unsigned int element);
> -- 
> 2.12.2
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list
> 

-- 
IBM Systems
Linux on z Systems & Virtualization Development
------------------------------------------------------------------------
IBM Deutschland
Schönaicher Str. 220
71032 Böblingen
Phone: +49 7031 16 1819
E-Mail: bwalk@xxxxxxxxxx
------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294 

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux