René's URL Explorer Experiment


Title: Call toJSON() on non-ext objects when it exists by kevincennis · Pull Request #188 · msgpack/msgpack-javascript · GitHub

Open Graph Title: Call toJSON() on non-ext objects when it exists by kevincennis · Pull Request #188 · msgpack/msgpack-javascript

X Title: Call toJSON() on non-ext objects when it exists by kevincennis · Pull Request #188 · msgpack/msgpack-javascript

Description: Currently, @msgpack/msgpack does not automatically call .toJSON() on objects which define that method. Since JSON and msgpack have significant overlap in semantics and intent, and toJSON() is a signal from an object that says "this is how I want to be serialized", I believe it makes sense to use toJSON() when it exists (after exhausting possible extensions). The concrete use-case for me was mongodb.ObjectId – which returns a simple string from toJSON(), but otherwise looks like: { _bsontype: string, id: Uint8Array } Effectively, this change helps msgpack more closely match the behavior of JSON.stringify(). It wasn't entirely clear to me where these tests should go. There's not much in the suite for testing the encode side. Most of the tests seem to sort of implicitly test encoding while calling themselves decode tests, so I've stuck with that convention here.

Open Graph Description: Currently, @msgpack/msgpack does not automatically call .toJSON() on objects which define that method. Since JSON and msgpack have significant overlap in semantics and intent, and toJSON() is a sig...

X Description: Currently, @msgpack/msgpack does not automatically call .toJSON() on objects which define that method. Since JSON and msgpack have significant overlap in semantics and intent, and toJSON() is a sig...

Opengraph URL: https://github.com/msgpack/msgpack-javascript/pull/188

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:3d3cb822-2b11-f6d9-15f1-d62caf8143a8
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8052:1B8E26:1024224:14E1140:69743074
html-safe-nonce2c40dc0ae81ae0cf6116a47b734d417583ff4fdb80e7e8528622ff8b15e7666e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDUyOjFCOEUyNjoxMDI0MjI0OjE0RTExNDA6Njk3NDMwNzQiLCJ2aXNpdG9yX2lkIjoiOTExOTQ1OTkzMDU3NzA1NTg2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacbf7f831dbaaba7b7b90e75b9b41bda4792cf2886f99eee180ba82b7a604a9b36
hovercard-subject-tagpull_request:717126121
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/msgpack/msgpack-javascript/pull/188/files
twitter:imagehttps://avatars.githubusercontent.com/u/868690?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/868690?s=400&v=4
og:image:altCurrently, @msgpack/msgpack does not automatically call .toJSON() on objects which define that method. Since JSON and msgpack have significant overlap in semantics and intent, and toJSON() is a sig...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonee0b95d743b7672c9ac0e1032d5f117950182dc164a83434a7db86510e8f0b37c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/msgpack/msgpack-javascript git https://github.com/msgpack/msgpack-javascript.git
octolytics-dimension-user_id198264
octolytics-dimension-user_loginmsgpack
octolytics-dimension-repository_id2761854
octolytics-dimension-repository_nwomsgpack/msgpack-javascript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id2761854
octolytics-dimension-repository_network_root_nwomsgpack/msgpack-javascript
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release56fe7e2e8de6e57740bca50402351ea656f7a4bf
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmsgpack%2Fmsgpack-javascript%2Fpull%2F188%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmsgpack%2Fmsgpack-javascript%2Fpull%2F188%2Ffiles
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=msgpack%2Fmsgpack-javascript
Reloadhttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files
Reloadhttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files
Reloadhttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files
msgpack https://patch-diff.githubusercontent.com/msgpack
msgpack-javascripthttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fmsgpack%2Fmsgpack-javascript
Fork 173 https://patch-diff.githubusercontent.com/login?return_to=%2Fmsgpack%2Fmsgpack-javascript
Star 1.5k https://patch-diff.githubusercontent.com/login?return_to=%2Fmsgpack%2Fmsgpack-javascript
Code https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript
Issues 16 https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/issues
Pull requests 4 https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pulls
Discussions https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/discussions
Actions https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/actions
Security 0 https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/security
Insights https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pulse
Code https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript
Issues https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/issues
Pull requests https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pulls
Discussions https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/discussions
Actions https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/actions
Security https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/security
Insights https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2Fmsgpack%2Fmsgpack-javascript%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2Fmsgpack%2Fmsgpack-javascript%2Fissues%2Fnew%2Fchoose
kevincennishttps://patch-diff.githubusercontent.com/kevincennis
msgpack:mainhttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/tree/main
kevincennis:mainhttps://patch-diff.githubusercontent.com/kevincennis/msgpack-javascript/tree/main
Conversation 8 https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188
Commits 1 https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/commits
Checks 0 https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/checks
Files changed https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files
Please reload this pagehttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files
Call toJSON() on non-ext objects when it exists https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#top
Show all changes 1 commit https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files
b04a351 Call toJSON() on non-ext objects when it exists kevincennis Aug 21, 2021 https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/commits/b04a35109940a6ada4c9a1c207990ebfd78eb0cf
Clear filters https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files
Please reload this pagehttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files
Please reload this pagehttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files
Encoder.ts https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#diff-2b07fa9965c82a4be8829b5cdcaff0dbd4e71fe8e601e353efcd72eee2e0c243
decodeAsync.test.ts https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#diff-19fbbd0d0f64db395bef2f11b4b72fd8b00b9b485ca682ae4d9d94db8188ba70
src/Encoder.tshttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#diff-2b07fa9965c82a4be8829b5cdcaff0dbd4e71fe8e601e353efcd72eee2e0c243
View file https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/blob/b04a35109940a6ada4c9a1c207990ebfd78eb0cf/src/Encoder.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#diff-2b07fa9965c82a4be8829b5cdcaff0dbd4e71fe8e601e353efcd72eee2e0c243
https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#diff-2b07fa9965c82a4be8829b5cdcaff0dbd4e71fe8e601e353efcd72eee2e0c243
https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#diff-2b07fa9965c82a4be8829b5cdcaff0dbd4e71fe8e601e353efcd72eee2e0c243
https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#diff-2b07fa9965c82a4be8829b5cdcaff0dbd4e71fe8e601e353efcd72eee2e0c243
test/decodeAsync.test.tshttps://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#diff-19fbbd0d0f64db395bef2f11b4b72fd8b00b9b485ca682ae4d9d94db8188ba70
View file https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/blob/b04a35109940a6ada4c9a1c207990ebfd78eb0cf/test/decodeAsync.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/msgpack/msgpack-javascript/pull/188/files#diff-19fbbd0d0f64db395bef2f11b4b72fd8b00b9b485ca682ae4d9d94db8188ba70
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.