-
-
Notifications
You must be signed in to change notification settings - Fork 774
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
replacer #339
Comments
I'm not sure this is needed here, but leave this open to collect feedback. |
Thanks for the comment. For background information: The reason we need the replacer is to prevent some objects getting placed in the output. We have an application using three.js, and many of my objects have associated THREE objects. However, when we dump the state we don't want to dump most of those, especially not the gory details of large vertex buffers, but rather recreate them after load. We used to use JSON, but it was very noisy, especially for multiline strings with double quotes,;so awkward when we needed to edit by hand. (At least it wasn't nearly as bad as XML) |
You could just create filtering function before calling yaml dump: |
I don't want to modify my data structure or clone the major part of it; which if I understand you right is what you expect |
In the same boat (wanting to discard |
See #391 for more discussion about this topic, includes also examples. Closed because it is a duplicate. |
Can we have this issue renamed to something like:
@sjpt I'd suggest an option like I'm still not sure if this feature is welcome.
If possible, could you please make it available as a PR (or as a branch in your fork), I'm interested in it anyways :-) |
I'll try to make a PR soon. My replacer is like the global replacer of JSON, not like the toJSON object function. Both have their place. How about options Actually, I specifically want to avoid 'toJSON' discussed in #391 as it is misused in three.js so for example |
Pull request created, I apologize if I have not done this correctly. |
PR is here: #392 I had a look and added some comments.
I see, you are talking about the JSON.stringify(value[, replacer[, space]])
In this case, should I re-open #391 ? Is that a problem of the 'toJSON' or of I'm looking for good arguments not to want//have/use/pursue
Do you have a link to this issue. I'm interested in the discussion. |
Found it: mrdoob/three.js#8428 With having an option to configure |
Thanks for finding that three.js issue of mine, I was about to hunt for it. I agree that configurable localReplacer makes this a non-issue now we are using yaml rather than JSON. In fact, for us the localReplacer is not needed at all, replacer does what we need. Also, it is easy just not to do I could make a deep copy of our structure without the THREE references and then serialize that, but that is much more work |
Not in my case, that is when the objects you serialize actually implement |
Added in 359b264 (currently in Tried to do this in a simplest possible way, so there're a few limitations:
|
I needed a yaml dumper that included a replacer option similar to JSON.stringify.
This turned out to be a simple modification to js-yaml; there may be details not covered.
Its use changes the handling of undefined fields so that they are omitted from the yaml (similar to JSON).
If there is any interest in this change I will make it available.
I will probably add a reviver option for parsing.
The text was updated successfully, but these errors were encountered: