GLib.Variant.parse

function parse(type: GLib.VariantType, text: String, limit: String, endptr: String): GLib.Variant {
    // Gjs wrapper for g_variant_parse()
}
  

Parses a GLib.Variant from a text representation.

A single GLib.Variant is parsed from the content of text.

The format is described [here][gvariant-text].

The memory at limit will never be accessed and the parser behaves as if the character at limit is the nul terminator. This has the effect of bounding text.

If endptr is non-null then text is permitted to contain data following the value that this function parses and endptr will be updated to point to the first character past the end of the text parsed by this function. If endptr is null and there is extra data then an error is returned.

If type is non-null then the value will be parsed to have that type. This may result in additional parse errors (in the case that the parsed value doesn't fit the type) but may also result in fewer errors (in the case that the type would have been ambiguous, such as with empty arrays).

In the event that the parsing is successful, the resulting GLib.Variant is returned.

In case of any error, null will be returned. If @error is non-null then it will be set to reflect the error that occurred.

Officially, the language understood by the parser is "any string produced by GLib.Variant.prototype.print".

type

a GLib.VariantType, or null

text

a string containing a GVariant in text form

limit

a pointer to the end of text, or null

endptr

a location to store the end pointer, or null

Returns

a reference to a GLib.Variant, or null