Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

Godot Variant Notation

An asset by WardensDev
The page banner background of a mountain and forest
Godot Variant Notation hero image

Quick Information

0 ratings
Godot Variant Notation icon image
WardensDev
Godot Variant Notation

Godot Variant Notation (GDVN) is a syntax built on top of JSON that allows for the easy parsing of any Godot Variant to and from Strings. GDVN uses the constructor syntax to encode Variants into Strings, which keeps your data readable and easily parse-able.The plugin provides a singleton/class called GDVN that functions exactly the same as Godot's built-in JSON class, making the conversion of existing JSON parsing code as simple as changing the class name.

Supported Engine Version
4.1
Version String
1.1
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

Godot Variant Notation

GDVN is a notation built on top of JSON that handles encoding Godot Variant data types into parsable strings.

Syntax

Godot Variants are formatted into Strings using their constructor syntax. For example:

{
    "test_vector": "Vector2(123, 456)",
    "test_rect": "Rect2(0.0, 0.0, 0.0, 0.0)"
}

Usage

GDVN is used exactly the same as Godot's built-in JSON class. (See: JSON Class Reference)

An example script is provided that demonstrates usage of the plugin.

Error parse(gdvn_text: String, keep_text: bool)

Non-static alternative to parse_string(). Returns an Error that can be used for custom error handling. The resulting data can be retrieved from the data member variable.

String get_error_message()

Returns the error message from the last failed parse() call.

int get_error_line()

Returns the line where the error occurred in the text of the last parse() call.

String get_parsed_text()

Returns the text that was parsed during the last parse() cal, if keep_text was true.

String stringify(data: Variant, indent: String = " ", sort_keys: bool = false, full_precision: bool = false)

Converts data into a String formatted using the Variant's constructor syntax. If data is a Dictionary or Array, this is done recursively for every key:value pair or element, then the data is converted to a String in JSON format.

Variant parse_string(data: String)

Converts a String encoded with stringify() back into a Variant.

Variant stringify_variants(data: Variant)

Converts a Variant into a String formatted using the Variant's constructor syntax. If data is a Dictionary or Array, this is done recursively for every key:value pair or element. Does not encode data into JSON format.

Variant parse_variant_strings(data: Variant)

Converts a constructor syntax String back into a Variant. If data is a Dictionary or Array, this is done recursively for every key:value pair or element. Does not encode data into JSON format.

Variant string_to_variant(data: String)

Converts a single constructor syntax String into a Variant.

Godot Variant Notation (GDVN) is a syntax built on top of JSON that allows for the easy parsing of any Godot Variant to and from Strings.

GDVN uses the constructor syntax to encode Variants into Strings, which keeps your data readable and easily parse-able.

The plugin provides a singleton/class called GDVN that functions exactly the same as Godot's built-in JSON class, making the conversion of existing JSON parsing code as simple as changing the class name.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Godot Variant Notation icon image
WardensDev
Godot Variant Notation

Godot Variant Notation (GDVN) is a syntax built on top of JSON that allows for the easy parsing of any Godot Variant to and from Strings. GDVN uses the constructor syntax to encode Variants into Strings, which keeps your data readable and easily parse-able.The plugin provides a singleton/class called GDVN that functions exactly the same as Godot's built-in JSON class, making the conversion of existing JSON parsing code as simple as changing the class name.

Supported Engine Version
4.1
Version String
1.1
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers