-
Notifications
You must be signed in to change notification settings - Fork 20
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
Circular references not detected/handled. #24
Comments
isn't this supposed to deal with circular references? i think those are circular references, anyway |
See the "To Do" section at the bottom of the readme: circular references are not currently detected. |
@Phrogz here's a way you could possibly do it:
|
@LoganDark I appreciate the suggestion. I know how to detect circular references, and I can think of several ways of handling them once detected. My preference would be to throw a custom error, since there is no valid way in JSON of properly representing an object with self-references, and I would not want to produce bad data that looks like it's a proper representation. I've chosen not to handle them so far because:
|
Than maybe something like a |
I can think of many different ways this would behave. Which of the following interest you? And why are they interesting? When would you use them? var circular = { a:{who:'a'}, b:{who:'b'} };
circular.a.b = circular.b;
circular.b.a = circular.a;
|
Why not implement them all? Of course you would have to implement it in whatever other language this is implemented in (I forgot, I think it's ruby) |
I think you misunderstand what I wrote. I was simply suggesting what the interface might look like for each option, and what the output might be like. There is no
Allow me to ~answer that by asking the question in a different way: "Why not do a lot of coding, for features that possibly no one will use, which will bloat the codebase and make it harder to maintain?" Hopefully the answer to that question is evident within the phrasing itself. :) Writing and maintaining code is a balance between functionality and maintainability. Feature creep and code scarring are the enemies. See YAGNI and "The Best Code You Will Ever Write". |
This feature request is on hold, pending more 'votes' for specific handling of circular references. |
with some huge objects:
and prettifier code:
The text was updated successfully, but these errors were encountered: