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
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3d3cb822-2b11-f6d9-15f1-d62caf8143a8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8052:1B8E26:1024224:14E1140:69743074 |
| html-safe-nonce | 2c40dc0ae81ae0cf6116a47b734d417583ff4fdb80e7e8528622ff8b15e7666e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDUyOjFCOEUyNjoxMDI0MjI0OjE0RTExNDA6Njk3NDMwNzQiLCJ2aXNpdG9yX2lkIjoiOTExOTQ1OTkzMDU3NzA1NTg2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bf7f831dbaaba7b7b90e75b9b41bda4792cf2886f99eee180ba82b7a604a9b36 |
| hovercard-subject-tag | pull_request:717126121 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/msgpack/msgpack-javascript/pull/188/files |
| twitter:image | https://avatars.githubusercontent.com/u/868690?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/868690?s=400&v=4 |
| og:image:alt | 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... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e0b95d743b7672c9ac0e1032d5f117950182dc164a83434a7db86510e8f0b37c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/msgpack/msgpack-javascript git https://github.com/msgpack/msgpack-javascript.git |
| octolytics-dimension-user_id | 198264 |
| octolytics-dimension-user_login | msgpack |
| octolytics-dimension-repository_id | 2761854 |
| octolytics-dimension-repository_nwo | msgpack/msgpack-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 2761854 |
| octolytics-dimension-repository_network_root_nwo | msgpack/msgpack-javascript |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 56fe7e2e8de6e57740bca50402351ea656f7a4bf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width