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.stringify a Object with circular references #403

Open
mrhut10 opened this issue Feb 25, 2021 · 1 comment
Open

JSON.stringify a Object with circular references #403

mrhut10 opened this issue Feb 25, 2021 · 1 comment

Comments

@mrhut10
Copy link

mrhut10 commented Feb 25, 2021

even though not a simple single liner, we is a lot of Object/Array comparisons in the provided examples which use the Stringify function, but the default replacer isn't circular reference safe.

the example I made in screenshot is circular reference safe, ( will skip over circular references ).

might be good to include it, but maybe not if we are thinking all of the examples must be single liners.

maybe its just worth mentioning in the single line examples as a comment that isn't circular reference safe, and link to a separe document (that isn't one liners) on how to handle those if they need to.

image

@elkarouani
Copy link
Contributor

I think that it's a special case, which that anyone can use a custom filter method as an argument for JSON.stringify() to find and replace (or remove) the cyclic references by serializable values. Sure it can't be resolved in one line, because then it will depends on that filter method that will not necessary be a single line function.

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

2 participants