-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Including a p5.Vector in saveJSON throws a circular structure error #5470
Comments
Oh, there is already a pull request to solve the vector issue specifically. #5469 Still, this may be present for other structures? |
#5469 will solve this problem for p5.Vector. Cyclic reference is still in the p5 instance itself and it will not be possible to be refactor out easily. I haven't come across anywhere else where it is a problem yet but if you find one let us know and we can look into it. |
Would it make sense to filter out p5 instances here regardless? That could be a blanket fix for beginners' accessibility. |
What do you mean? |
Resolved by #5469 |
Submitting an object with a p5.Vector object throws a TypeError. Test code and associated error:
I think two solutions are possible:
Filter out any p5 object properties transparent to the end user.
This would involve assessing p5.Vector and any other built-in classes for error-throwing content and making a custom replacer function to replace these with simplified or string equivalents.
Expand the saveJSON arguments to include a user-provided replacer.
Here is some possible code for this:
Both of the above
We could make a basic replacer and then allow a user to provide their own to either compound or override the filter.Location of code edit:
p5.js/src/io/files.js
Line 1578 in cb3f597
The text was updated successfully, but these errors were encountered: