[ CCode ( returns_floating_reference = true ) ]
[ Version ( since = "0.14" ) ]
public Variant? gvariant_deserialize_data (string json, ssize_t length, string? signature) throws Error
Converts a JSON string to a `GVariant` value.
This function works exactly like [[email protected]_deserialize], but takes a JSON encoded string instead.
The string is first converted to a [[email protected]] using [[email protected]], and then `json_gvariant_deserialize` is called on the node.
The returned variant has a floating reference that will need to be sunk by the caller code.
Example: GVariant deserialization (string):
public static int main (string[] args) {
try {
string data = """{ "a" : 3, "b" : 4 }""";
// Deserialization:
Variant variant = Json.gvariant_deserialize_data (data, -1, null);
print (variant.print (true));
print ("\n");
} catch (Error e) {
assert_not_reached ();
}
return 0;
}
valac --pkg json-glib-1.0 deserialization-variant-data.vala
json |
A JSON data string |
length |
The length of |
signature |
A valid `GVariant` type string |
A newly created `GVariant`D compliant |