Ran into an issue in no signal where
Godot was loading Vector2i
values as
String
values. As it turns out, this is
because Godot's JSON implementation does not round
trip correctly:
extends Node
func _ready() -> void:
var value: Vector2i = Vector2i(3,2)
var string = JSON.stringify(value)
print("String: ", string)
var parsed = JSON.parse_string(string)
print("Value: ", parsed)
print("Value is String? ", parsed is String)
print("Value is Vector2i? ", parsed is Vector2i)
The above code outputs:
String: "(3, 2)"
Value: (3, 2)
Value is String? true
Value is Vector2i? false
As you can see, Godot converts the
Vector2i
to a JSON string without any
type information, so it can only reasonably parse
the JSON string as a String
when
parse_string
is called.
Instead, I was able to get around this issue by
using var_to_str
and
str_to_var
instead of the
JSON
API.