SYNOPSIS

my $v = Glib::Variant->new ('as', ['GTK+', 'Perl']);
my $aref = $v->get ('as');

DESCRIPTION

There are two sets of APIs for creating and dealing with Glib::Variants: the low-level API described below under "METHODS", and the convenience API described in this section.

CONVENIENCE API

variant = Glib::Variant->new ($format_string, $value)
(variant1, ...) = Glib::Variant->new ($format_string, $value1, ...)

Constructs a variant from $format_string and $value. Also supports constructing multiple variants when the format string is a concatenation of multiple types.

value = $variant->get ($format_string)

Deconstructs $variant according to $format_string.

The following symbols are currently supported in format strings:

+------------------------------+---------------------------------+
|            Symbol            |             Meaning             |
+------------------------------+---------------------------------+
| b, y, n, q, i, u, x, t, h, d | Boolean, byte and numeric types |
| s, o, g                      | String types                    |
| v                            | Variant types                   |
| a                            | Arrays                          |
| m                            | Maybe types                     |
| ()                           | Tuples                          |
| {}                           | Dictionary entries              |
+------------------------------+---------------------------------+

Note that if a format string specifies an array, a tuple or a dictionary entry ("a", "()" or "{}"), then array references are expected by new and produced by get. For arrays of dictionary entries ("a{}"), hash references are also supported by new and handled as you would expect.

For a complete specification, see the documentation at

https://developer.gnome.org/glib/stable/glib-GVariantType.html
https://developer.gnome.org/glib/stable/glib-GVariant.html
https://developer.gnome.org/glib/stable/gvariant-format-strings.html
https://developer.gnome.org/glib/stable/gvariant-text.html