René's URL Explorer Experiment


Title: how to handle undefined values cleanly? · Issue #571 · nodeca/js-yaml · GitHub

Open Graph Title: how to handle undefined values cleanly? · Issue #571 · nodeca/js-yaml

X Title: how to handle undefined values cleanly? · Issue #571 · nodeca/js-yaml

Description: I'm dump ing an object, and fields without values come out like this: fieldName: ! '' how can I suppress that to either undefined or just to skip it like JSON.stringify ? I tried some options from the safe...

Open Graph Description: I'm dump ing an object, and fields without values come out like this: fieldName: ! '' how can I suppress that to either undefined or just to skip it like JSON.string...

X Description: 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 i...

Opengraph URL: https://github.com/nodeca/js-yaml/issues/571

X: @github

direct link

Domain: redirect.github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"how to handle undefined values cleanly?","articleBody":"I'm `dump` ing an object, and fields without values come out like this:\r\n\r\n`fieldName: !\u003ctag:yaml.org,2002:js/undefined> ''`\r\n\r\nhow can I suppress that to either `undefined` or just to skip it like `JSON.stringify` ?\r\n\r\nI tried some options from the `safeDump` \r\n\r\n`const blob = yaml.dump(obj, { skipInvalid: true, lineWidth: 200 })`\r\n\r\nhttps://github.com/nodeca/js-yaml#safedump-object---options-\r\n\r\nbut 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 for `false` vs `undefined` etc. etc.\r\n\r\nI tried this but it didn't have any effect:\r\n`const clean = { ...obj } // remove nulls?` \r\n\r\nSure there must be a nicer way to handle this with `js-yaml` ?\r\nDo I have to define my own schema?\r\n\r\nrelated:\r\nhttps://github.com/nodeca/js-yaml/issues/456\r\nhttps://stackoverflow.com/a/38340374/1146785\r\n\r\n\r\n```js\r\n\r\n  async debugMessage(obj) {\r\n    console.log('json', JSON.stringify(obj, null, 2))\r\n    const blob = yaml.dump(obj)\r\n    console.log('yaml', blob)\r\n  }\r\n\r\n\r\n// json \r\n\r\n{\r\n  \"msg\": \"router\",\r\n  \"input\": \"sleep\",\r\n  \"eventType\": \"action\",\r\n  \"handled\": {\r\n    \"handled\": true,\r\n    \"doc\": {\r\n      \"match\": \"^cont|.*\",\r\n      \"goto\": \"prologue\"\r\n    },\r\n    \"klass\": \"room\",\r\n    \"history\": [\r\n      \"goto\"\r\n    ]\r\n  }\r\n}\r\n\r\n// yaml \r\n\r\nmsg: router\r\ninput: sleep\r\neventType: action\r\nparsed: !\u003ctag:yaml.org,2002:js/undefined> ''\r\nhandled:\r\n  handled: true\r\n  doc:\r\n    match: ^cont|.*\r\n    goto: prologue\r\n  klass: room\r\n  history:\r\n    - goto\r\n\r\n````\r\n","author":{"url":"https://github.com/dcsan","@type":"Person","name":"dcsan"},"datePublished":"2020-07-25T23:43:52Z","url":"https://github.com/nodeca/js-yaml/issues/571"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:66902c7e-5da6-9574-1d57-722b4b548589
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD322:23CD5:45B872:5DB0F4:6AEDB651
html-safe-nonce96c4e3d1dd78d26054d4dd8a1da93805a8e95f284b983efc28bc62e10f6db431
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzIyOjIzQ0Q1OjQ1Qjg3Mjo1REIwRjQ6NkFFREI2NTEiLCJ2aXNpdG9yX2lkIjoiMTU0ODQwNjkyNjg1NDY5ODU3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac99fdcb35c494b2e2aa439cc6bd9ba7181d461681dbbf4a28185c992ac72bfd97
hovercard-subject-tagissue:665678692
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodeca/js-yaml/571/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d7e8bab38d62234fdba62231ad5481d2a13efeb8bde09c3213893fb0c64ab335/nodeca/js-yaml/issues/571
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d7e8bab38d62234fdba62231ad5481d2a13efeb8bde09c3213893fb0c64ab335/nodeca/js-yaml/issues/571
og:image:altI'm dump ing an object, and fields without values come out like this: fieldName: ! '' how can I suppress that to either undefined or just to skip it like JSON.string...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedcsan
hostnamegithub.com
expected-hostnamegithub.com
None1eb5f7cedbc707472687eab1a30e6c4619c00791815622ceaba9694eb161930f
turbo-cache-controlno-preview
go-importgithub.com/nodeca/js-yaml git https://github.com/nodeca/js-yaml.git
octolytics-dimension-user_id723678
octolytics-dimension-user_loginnodeca
octolytics-dimension-repository_id2504175
octolytics-dimension-repository_nwonodeca/js-yaml
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id2504175
octolytics-dimension-repository_network_root_nwonodeca/js-yaml
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef31f9c89203c022acdb651c34ae048cf41764208
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://redirect.github.com/nodeca/js-yaml/issues/571#start-of-content
https://redirect.github.com/
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodeca%2Fjs-yaml%2Fissues%2F571
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodeca%2Fjs-yaml%2Fissues%2F571
Sign uphttps://redirect.github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodeca%2Fjs-yaml
Reloadhttps://redirect.github.com/nodeca/js-yaml/issues/571
Reloadhttps://redirect.github.com/nodeca/js-yaml/issues/571
Reloadhttps://redirect.github.com/nodeca/js-yaml/issues/571
nodecahttps://redirect.github.com/nodeca
js-yamlhttps://redirect.github.com/nodeca/js-yaml
Codehttps://redirect.github.com/nodeca/js-yaml
Issues5 (5)https://redirect.github.com/nodeca/js-yaml/issues
Pull requests1 (1)https://redirect.github.com/nodeca/js-yaml/pulls
Actionshttps://redirect.github.com/nodeca/js-yaml/actions
Security and quality9 (9)https://redirect.github.com/nodeca/js-yaml/security
Insightshttps://redirect.github.com/nodeca/js-yaml/pulse
https://redirect.github.com/nodeca/js-yaml
New issuehttps://redirect.github.com/login?return_to=https://github.com/nodeca/js-yaml/issues/571
New issuehttps://redirect.github.com/login?return_to=https://github.com/nodeca/js-yaml/issues/571
how to handle undefined values cleanly?https://redirect.github.com/nodeca/js-yaml/issues/571#top
https://github.com/dcsan
dcsanhttps://github.com/dcsan
on Jul 25, 2020https://github.com/nodeca/js-yaml/issues/571#issue-665678692
https://github.com/nodeca/js-yaml#safedump-object---options-https://github.com/nodeca/js-yaml#safedump-object---options-
#456https://github.com/nodeca/js-yaml/issues/456
https://stackoverflow.com/a/38340374/1146785https://stackoverflow.com/a/38340374/1146785
https://redirect.github.com/dcsan
dcsanhttps://redirect.github.com/dcsan
on Aug 26, 2020https://github.com/nodeca/js-yaml/issues/571#issuecomment-680925865
https://redirect.github.com/aeisenberg
aeisenberghttps://redirect.github.com/aeisenberg
on Sep 11, 2020https://github.com/nodeca/js-yaml/issues/571#issuecomment-691238648
https://redirect.github.com/NelsonFrancisco
NelsonFranciscohttps://redirect.github.com/NelsonFrancisco
on Nov 4, 2020https://github.com/nodeca/js-yaml/issues/571#issuecomment-721944729
rlidwkahttps://redirect.github.com/rlidwka
on Dec 18, 2020https://github.com/nodeca/js-yaml/issues/571#event-4130774045
Serialize undefined as null in collections, remove it in mappingshttps://github.com/nodeca/js-yaml/commit/56d5616938af5be943074222b9b10e0519b170b7
56d5616https://github.com/nodeca/js-yaml/commit/56d5616938af5be943074222b9b10e0519b170b7
https://redirect.github.com/rlidwka
rlidwkahttps://redirect.github.com/rlidwka
on Dec 18, 2020https://github.com/nodeca/js-yaml/issues/571#issuecomment-748221455
56d5616https://github.com/nodeca/js-yaml/commit/56d5616938af5be943074222b9b10e0519b170b7
rlidwkahttps://redirect.github.com/rlidwka
completedhttps://redirect.github.com/nodeca/js-yaml/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Dec 18, 2020https://github.com/nodeca/js-yaml/issues/571#event-4130791021
https://redirect.github.com/mk-pmb
mk-pmbhttps://redirect.github.com/mk-pmb
on Dec 29, 2020https://github.com/nodeca/js-yaml/issues/571#issuecomment-751940961
Sign up for freehttps://redirect.github.com/signup?return_to=https://github.com/nodeca/js-yaml/issues/571
Sign in to commenthttps://redirect.github.com/login?return_to=https://github.com/nodeca/js-yaml/issues/571
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.