### Method

# GLib Variant get_data

since: 2.24

#### Declaration [src]

    gconstpointer
    g_variant_get_data (
      GVariant* value
    )

#### Description [src]

Returns a pointer to the serialized form of a `GVariant` instance. The returned data may not be in fully-normalised form if read from an untrusted source. The returned data must not be freed; it remains valid for as long as `value` exists.

If `value` is a fixed-sized value that was deserialized from a corrupted serialized container then `NULL` may be returned. In this case, the proper thing to do is typically to use the appropriate number of nul bytes in place of `value`. If `value` is not fixed-sized then `NULL` is never returned.

In the case that `value` is already in serialized form, this function is O(1). If the value is not already in serialized form, serialization occurs implicitly and is approximately O(n) in the size of the result.

To deserialize the data returned by this function, in addition to the serialized data, you must know the type of the `GVariant`, and (if the machine might be different) the endianness of the machine that stored it. As a result, file formats or network messages that incorporate serialized `GVariants` must include this information either implicitly (for instance “the file always contains a `G_VARIANT_TYPE_VARIANT` and it is always in little-endian order”) or explicitly (by storing the type and/or endianness in addition to the serialized data).

Available since: 2.24

#### Return value

Type: `gconstpointer`

The serialized form of `value`, or `NULL`.

The returned data is owned by the instance.
The return value can be `NULL`.