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 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

Parameters:

variant

A Variant to convert

length

the length of the returned string

Returns:

The JSON encoded string corresponding to the given variant


Namespace: Json
Package: json-glib-1.0



2022 vala-language.org