gvariant_serialize_data


Description:

[ Version ( since = "0.14" ) ]
public string gvariant_serialize_data (Variant variant, out size_t length)

Converts variant to its JSON encoded string representation.

This method is actually a helper function. It uses gvariant_serialize to obtain the JSON tree, and then Generator 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

Parameters:

variant

A Variant to convert

length

Return location for the length of the returned string, or null

Returns:

The JSON encoded string corresponding to variant


Namespace: Json
Package: json-glib-1.0