GLib.Variant.get_child_value

### Method

# GLib Variantget_child_value

since: 2.24

#### Declaration

    GVariant*
    g_variant_get_child_value (
      GVariant* value,
      gsize index_
    )

#### Description

Reads a child item out of a container `GVariant` instance. This includes variants, maybes, arrays, tuples and dictionary entries. It is an error to call this function on any other type of `GVariant`.

It is an error if `index_` is greater than the number of child items in the container. See g_variant_n_children().

The returned value is never floating. You should free it with `g_variant_unref()` when you’re done with it.

Note that values borrowed from the returned child are not guaranteed to still be valid after the child is freed even if you still hold a reference to `value`, if `value` has not been serialized at the time this function is called. To avoid this, you can serialize `value` by calling `g_variant_get_data()` and optionally ignoring the return value.

There may be implementation specific restrictions on deeply nested values, which would result in the unit tuple being returned as the child value, instead of further nested children. `GVariant` is guaranteed to handle nesting up to at least 64 levels.

This function is O(1).

Available since: 2.24

#### Parameters

`index_`

  Type: `gsize`

  The index of the child to fetch.

#### Return value

Type: `GVariant`

The child at the specified index.

The caller of the method takes ownership of the data, and is responsible for freeing it.