Closed herve-ch closed 1 week ago
Could you give me a code example that shows the problem? It would really help me understand what's going on. Please include any important details or steps to reproduce the issue. Thanks!
ok I'll try to make a mini project and post here
Here is a mini project, I want to save a class with a property that inherits a superclass (MyChildClass). I save it in json, when I get it back the Save Class, it property is of type MySuperClass
Here is a mini project, I want to save a class with a property that inherits a superclass (MyChildClass). I save it in json, when I get it back the Save Class, it property is of type MySuperClass
Where is the code?
test-serialize-json-project.zip
Oops sorry here is the project
It does work.
the test member is of type MySuperClass. I created it with Type MyChildClass
var child_class:MyChildClass = MyChildClass.new() child_class.my_child_prop="child_prop" child_class.my_super_prop="super_prop" save.test=child_class
In your screenshot test member has only super prop member, I lost the my_child_prop
Save file in json is correct: { "ScriptName": "Save", "test": { "ScriptName": "MyChildClass", "my_child_prop": "child_prop", "my_super_prop": "super_prop" } }
test should be of type MyChildClass
the test member is of type MySuperClass. I created it with Type MyChildClass
var child_class:MyChildClass = MyChildClass.new() child_class.my_child_prop="child_prop" child_class.my_super_prop="super_prop" save.test=child_class
In your screenshot test member has only super prop member, I lost the my_child_prop
Got it! The child_class is set up as the inherited class, but in save.gd it's supposed to be MySuperClass. Thanks for spotting this!
no problem lol good luck and thx for this great tool!
the test member is of type MySuperClass. I created it with Type MyChildClass
var child_class:MyChildClass = MyChildClass.new() child_class.my_child_prop="child_prop" child_class.my_super_prop="super_prop" save.test=child_class
In your screenshot test member has only super prop member, I lost the my_child_propGot it! The child_class is set up as the inherited class, but in save.gd it's supposed to be MySuperClass. Thanks for spotting this!
Wait i dont Know if I understand well but for me, the save file is correct. The json to class should return the inherited class MyChildClass And not the superclass.
the test member is of type MySuperClass. I created it with Type MyChildClass
var child_class:MyChildClass = MyChildClass.new() child_class.my_child_prop="child_prop" child_class.my_super_prop="super_prop" save.test=child_class
In your screenshot test member has only super prop member, I lost the my_child_propGot it! The child_class is set up as the inherited class, but in save.gd it's supposed to be MySuperClass. Thanks for spotting this!
Wait i dont Know if I understand well but for me, the save file is correct. The json to class should return the inherited class MyChildClass And not the superclass.
I made a fix, try updating your jsonclassconverter to match the last commit, and let me know if it works now. Here
the test member is of type MySuperClass. I created it with Type MyChildClass
var child_class:MyChildClass = MyChildClass.new() child_class.my_child_prop="child_prop" child_class.my_super_prop="super_prop" save.test=child_class
In your screenshot test member has only super prop member, I lost the my_child_propGot it! The child_class is set up as the inherited class, but in save.gd it's supposed to be MySuperClass. Thanks for spotting this!
Wait i dont Know if I understand well but for me, the save file is correct. The json to class should return the inherited class MyChildClass And not the superclass.
I made a fix, try updating your jsonclassconverter to match the last commit, and let me know if it works now. Here
Thanks!! will try when i get home
Thanks a lot
Hello
I tried to serialize a class with a member that inherit another class but when using json to class, the inherited class will be lost (will only be the superclass) I dont know if it's fixable since you use typedef in class for deserializing? The json file has the correct child class in it tho
Thanks