Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inst2dict does not turn classes inside classes to dict #6533

Open
Tracked by #33348
ivanskodje opened this issue Sep 18, 2016 · 8 comments
Open
Tracked by #33348

inst2dict does not turn classes inside classes to dict #6533

ivanskodje opened this issue Sep 18, 2016 · 8 comments

Comments

@ivanskodje
Copy link
Contributor

ivanskodje commented Sep 18, 2016

inst2dict does not turn classes inside classes to dict.

Here is an example of to_json() output;

{
	"description": "Some Desc",
	"id": 1337,
	"@path": "res://data/classes/project_class.gd",
	"tasks": [
		"[Reference:835]",
		"[Reference:836]",
		"[Reference:837]"
	],
	"@subpath": "",
	"name":"P Name"
}

I believe the classes (Reference:8XX) should also be converted to Dictionary for this to work as intended. :)

Currently; a workaround for this is to save the other classes as Dict, and use a set/get where you convert between class and dictionary. However I am sure inst2dict should also include subclasses.

Hope to see a fix implemented in the future :)

@Geequlim
Copy link
Contributor

Geequlim commented Aug 8, 2017

The functions inst2dict and dict2inst should handle the members of a script instance recursely.
And also they should could be used for all of script languages instead of GDScript only.

@Geequlim
Copy link
Contributor

Geequlim commented Aug 8, 2017

@bojidar-bg Any idea with this?

@bojidar-bg
Copy link
Contributor

No, I never touched inst2dict/dict2inst code so far. I guess I might, if this issue sticks around 😆

@ghost
Copy link

ghost commented Apr 6, 2018

First of all thank you for your report and sorry for the delay.

We released Godot 3.0 in January 2018 after 18 months of work, fixing many old issues either directly, or by obsoleting/replacing the features they were referring to.

We still have hundreds of issues whose relevance/reproducibility needs to be checked against the current stable version, and that's where you can help us.
Could you check if the issue that you described initially is still relevant/reproducible in Godot 3.0 or any newer version, and comment about it here?

For bug reports, please also make sure that the issue contains detailed steps to reproduce the bug and, if possible, a zipped project that can be used to reproduce it right away. This greatly speeds up debugging and bugfixing tasks for our contributors.

Our Bugsquad will review this issue more in-depth in 15 days, and potentially close it if its relevance could not be confirmed.

Thanks in advance.

Note: This message is being copy-pasted to many "stale" issues (90+ days without activity). It might happen that it is not meaningful for this specific issue or appears oblivious of the issue's context, if so please comment to notify the Bugsquad about it.

@Xrayez
Copy link
Contributor

Xrayez commented Jun 29, 2018

I've stumbled upon the same issue when I needed to serialize data. I made a few attempts to modify inst2dict method using simple recursion. There should be definitely better ways to achieve this, but it seems to work (tested on 3 classes using inner instances of each other).

While trying to find a fix, I've also realized the same conversion should be done on properties that possibly have arrays of instances. For some reason I can't get it to work on arrays (most likely because of recursion hell).

@Geequlim
Copy link
Contributor

@Rinkton
Copy link

Rinkton commented May 23, 2022

I made a script, that fixes that bug and made inst2dict() and dict2inst() functions more convenient to use overall: Github repos

@YuriSizov YuriSizov modified the milestones: 4.0, 4.x Feb 22, 2023
pafuent added a commit to pafuent/godot that referenced this issue Sep 20, 2024
Fixes godotengine#6533

Making GDScript inst_to_dict/dict_to_inst utility functions recursive.
Adding also a new macro to validate the number of the required arguments.
pafuent added a commit to pafuent/godot that referenced this issue Sep 20, 2024
Fixes godotengine#6533

Making GDScript inst_to_dict/dict_to_inst utility functions recursive.
Adding also a new macro to validate the number of the required arguments.
pafuent added a commit to pafuent/godot that referenced this issue Sep 20, 2024
Fixes godotengine#6533

Making GDScript inst_to_dict/dict_to_inst utility functions recursive.
Adding also a new macro to validate the number of the required arguments.
pafuent added a commit to pafuent/godot that referenced this issue Sep 20, 2024
Fixes godotengine#6533

Making GDScript inst_to_dict/dict_to_inst utility functions recursive.
Adding also a new macro to validate the number of the required arguments
and another to validate that an argument is boolean.
pafuent added a commit to pafuent/godot that referenced this issue Sep 20, 2024
Fixes godotengine#6533

Making GDScript inst_to_dict/dict_to_inst utility functions recursive.
Adding also a new macro to validate the number of the required arguments
and another to validate that an argument is boolean.
pafuent added a commit to pafuent/godot that referenced this issue Oct 17, 2024
Fixes godotengine#6533

Making GDScript inst_to_dict/dict_to_inst utility functions recursive.
Adding also a new macro to validate the number of the required arguments
and another to validate that an argument is boolean.
pafuent added a commit to pafuent/godot that referenced this issue Nov 1, 2024
Fixes godotengine#6533

Making GDScript inst_to_dict/dict_to_inst utility functions recursive.
Adding also a new macro to validate the number of the required arguments
and another to validate that an argument is boolean.
pafuent added a commit to pafuent/godot that referenced this issue Nov 5, 2024
Fixes godotengine#6533

Making GDScript inst_to_dict/dict_to_inst utility functions recursive.
Adding also a new macro to validate the number of the required arguments
and another to validate that an argument is boolean.
pafuent added a commit to pafuent/godot that referenced this issue Nov 12, 2024
Fixes godotengine#6533

Making GDScript inst_to_dict/dict_to_inst utility functions recursive.
Adding also a new macro to validate the number of the required arguments
and another to validate that an argument is boolean.
@AThousandShips
Copy link
Member

For 4.x this method is now deprecated, so this is now only really relevant for 3.x:

@AThousandShips AThousandShips modified the milestones: 4.x, 3.x Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet