gvariant_serialize
Description:
Converts `variant` to a JSON tree.
Example: GVariant serialization:
public static int main (string[] args) {
// Create a variant:
Variant variant = new Variant.strv ({
"str-1",
"str-2",
"str-3"
});
// Serialize it:
Json.Node root = Json.gvariant_serialize (variant);
// To string: (see gobject_to_data)
Json.Generator generator = new Json.Generator ();
generator.set_root (root);
string data = generator.to_data (null);
// Output:
// ``["str-1","str-2","str-3"]``
print (data);
print ("\n");
return 0;
}
valac --pkg json-glib-1.0 serialization-variant.vala
Parameters:
variant |
A `GVariant` to convert |
Returns:
the root of the JSON data structure obtained from `variant` |
Namespace: Json
Package: json-glib-1.0