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

JSON Object for Classes which contain nested arrays of Objects. #40

Open
uyu34 opened this issue Aug 19, 2020 · 1 comment
Open

JSON Object for Classes which contain nested arrays of Objects. #40

uyu34 opened this issue Aug 19, 2020 · 1 comment

Comments

@uyu34
Copy link

uyu34 commented Aug 19, 2020

Hello,

Thank you for making this plugin, it is doing a lot of great things.

However, I am having an issue with the JSON data I am sending and receiving with a custom class. This custom class contains some Arrays of other custom classes which also contain arrays of other custom classes. When I print the JSON as a string or to the log, the data doesn't look like the intended format and instead it almost appears as each element in the array is just a file.

Would love if you can provide some feedback on this. I have included a screenshot of the output.

Please let me know if you need a better explaination.
ObjectDelivererLog

@uyu34
Copy link
Author

uyu34 commented Sep 2, 2020

So for anyone else using this Object Deliverer who has the same issue... I solved it by writing custom JSON serialization for each class with nested objects. In the serialization of the parent object when we get to a nested object we call its serialization as well. If that object also has nested objects we can call them within the first nested object's serialization. Once all the serialization is done we can send the JSON as a string over the network with TCP and when it's received reconstruct by writing your own logic that converts JSON back into the classtype.

If you use this approach be careful with circular references, as you will likely create an infinite loop.

There may be a better approach to solving this problem that already exists in the system that I am not aware of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant