-
-
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
how to handle undefined values cleanly? #571
Comments
bump super annoying. currently I have to do this:
or the parse results default to full of junk
|
I'm having the same problem. Here's my solution, which won't work if you have a circular object or are using any special yaml types:
|
An option would be a nice addition 👍 |
Fixed in 56d5616 (currently in Now
If user defines custom schema for |
I'd like an option what do with |
I'm
dump
ing an object, and fields without values come out like this:fieldName: !<tag:yaml.org,2002:js/undefined> ''
how can I suppress that to either
undefined
or just to skip it likeJSON.stringify
?I tried some options from the
safeDump
const blob = yaml.dump(obj, { skipInvalid: true, lineWidth: 200 })
https://github.com/nodeca/js-yaml#safedump-object---options-
but without success. I guess I can strip out the undefined fields, but I'd have to do a
deep
clean of the whole object... also check forfalse
vsundefined
etc. etc.I tried this but it didn't have any effect:
const clean = { ...obj } // remove nulls?
Sure there must be a nicer way to handle this with
js-yaml
?Do I have to define my own schema?
related:
#456
https://stackoverflow.com/a/38340374/1146785
The text was updated successfully, but these errors were encountered: