Converts variant
to its JSON encoded string representation.
This is a convenience function around [[email protected]_serialize], to obtain the JSON tree, and then [[email protected]] to stringify it.
Example: GVariant serialization (string):
public static int main (string[] args) {
// Create a variant:
Variant variant = new Variant.strv ({
"str-1",
"str-2",
"str-3"
});
// Serialize it:
// Outut: ``["str-1","str-2","str-3"]``
string data = Json.gvariant_serialize_data (variant, null);
print (data);
print ("\n");
return 0;
}
valac --pkg json-glib-1.0 serialization-variant-data.vala
variant |
A Variant to convert |
length |
the length of the returned string |
The JSON encoded string corresponding to the given variant |