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

Update toJSON example in JSDOCs #8303

Open
asturur opened this issue Sep 19, 2022 · 2 comments
Open

Update toJSON example in JSDOCs #8303

asturur opened this issue Sep 19, 2022 · 2 comments

Comments

@asturur
Copy link
Member

asturur commented Sep 19, 2022

toJSON examples are still referencing additional properties and should be updated to reflect the recent change, they don't support additional properties anymore indeed.

@SandeepUrankar
Copy link

Hey, could you please tell me more about it?

@asturur
Copy link
Member Author

asturur commented Sep 13, 2023

we had toObject as an alias of toJSON.
By javascript specs toJSON
https://tc39.es/ecma262/multipage/structured-data.html#sec-json.stringify
is called with key as first argument for nested objects.

Our toObject function accepts a parameter that is an array of properties, while toJSON can't don't that because the first argument is defined by javascript specs.

our examples in the codebase treated toObject as toJson, so you will find in the codebase a string like this:

   * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);

where this is wrong.

it can either be:

   * var json = canvas.toObject(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);

or

   * var json = canvas.toJSON();

So that wrong toJSON example needs to be deleted and if other are found need to be deleted as well.

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

No branches or pull requests

2 participants