Godot Version
4.6.1.stable
Question
While extending my save/load mechanism, I encountered a weird situation. I am trying to save a list of Dictionary, each of them having one of the record being a nested Dictionary. In this nested Dictionary, the values are themselves a Dictionary, with keys and values as integer.
Here is how the data would look like:
dict:Dictionary = {
&"filename": "res://locations/house.tscn",
&"history": {%"item1": {1:10}, %"item2": {1:20}},
}
I am saving my data using the JSON methods. Here is the code I am using:
var save_file = FileAccess.open(location_save_path, FileAccess.WRITE)
for dict:Dictionary in locations_data:
var json_string = JSON.stringify(dict)
save_file.store_line(json_string)
When doing so, the value of json_string becomes:
{"history":{"item1":{"1":10},"item2":{"1":20}},"filename":"res://locations/ciaran_house.tscn"}
As you can see, the Keys of the second-level Dictionary, which were integer in the original variable, are converted in String (but not the Values). This seemed like a quite random behaviour, but there might be a good explanation. Is it something I am doing in the way I try to use the Stringify method? Is it possible to avoid this conversion?
Thanks